google / cel-go

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

[Policy Compiler] Surface type-mismatches error in a more readable fashion #973

Closed l46kok closed 1 month ago

l46kok commented 2 months ago

Policy compiler will fail to type-check the composed policies (expectedly) if their output types are different. Example:

name: foo_policy
rule:
    match:
       - condition: x
         output: "error"
       - output: true
Compile() failed: ERROR: testdata/nested_rule/policy.yaml:-1:0: found no matching overload for '_?_:_' applied to '(bool, map(string, bool), string)'

We should try to raise this error in a more readable fashion, and ideally with the source positions wrt/ yaml.

(xref b/350064634 for Java impl)