google / cel-go

Fast, portable, non-Turing complete expression evaluation with gradual typing (Go)
https://cel.dev
Apache License 2.0
2.31k stars 225 forks source link

Introduce a flag for supporting 'null' as absent on optional field selection #938

Closed TristonianJones closed 7 months ago

TristonianJones commented 7 months ago

Due to a bug in the original implementation of optional values, a field selection on a null value would produce optional.none() rather than an error. This bug was fixed in #922; however, the bug has been relied upon as a feature within upstream software.

To preserve the legacy behavior, configure the following option:

cel.NewEnv(cel.OptionalTypes(), cel.OptionalFieldSelectionNoneIfNull(true)))

Closes #937

jcking commented 7 months ago

LGTM assuming we also add a conformance test to cel-spec