Commit 85ab10f
committed
fix(interpreter): propagate unknown/error operands through == and !=
EvalEq and EvalNe evaluated their operands and called lhs.equal(rhs)
directly, without first checking whether either operand was unknown or
error. Because UnknownT.equal(...) returns BoolT.False, any "==" against
an unknown collapsed to a concrete false (and "!=" to a concrete true)
during partial evaluation, instead of propagating the unknown.
The sibling EvalBinary (used by <, <=, >, >=) already guards with
isUnknownOrError, and cel-go guards its equality evaluators the same way.
Add the same guard to EvalEq and EvalNe so an undecidable equality is
deferred rather than resolved.
This fixes residual-AST / partial evaluation: a policy of the form
`... && claims.email == "x"` evaluated with `email` unknown now yields a
residual of the deferred comparison instead of collapsing the whole
expression to false. ResidualAst_Complex is updated to assert the
corrected (unknown-propagating) outcome, and a focused regression test,
InterpreterTest.equalityWithUnknownOperandStaysUnknown, is added.1 parent 11b8c8c commit 85ab10f
3 files changed
Lines changed: 42 additions & 3 deletions
File tree
- core/src
- main/java/org/projectnessie/cel/interpreter
- test/java/org/projectnessie/cel
- interpreter
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
399 | 406 | | |
400 | 407 | | |
401 | 408 | | |
| |||
439 | 446 | | |
440 | 447 | | |
441 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
442 | 456 | | |
443 | 457 | | |
444 | 458 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
| |||
657 | 656 | | |
658 | 657 | | |
659 | 658 | | |
660 | | - | |
| 659 | + | |
661 | 660 | | |
662 | 661 | | |
663 | | - | |
| 662 | + | |
664 | 663 | | |
665 | 664 | | |
666 | 665 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1505 | 1505 | | |
1506 | 1506 | | |
1507 | 1507 | | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1508 | 1534 | | |
1509 | 1535 | | |
1510 | 1536 | | |
| |||
0 commit comments