Commit 84f0136
committed
fix: has() on non-container types returns error instead of false
has() applied to a non-container, non-optional value (e.g., an integer
or string) previously returned false silently when
errorOnBadPresenceTest was not enabled. This caused !has(x.field) to
evaluate to true when x was an unexpected type, creating a fail-open
condition in policy expressions that use presence guards on dynamic
inputs.
This change narrows the default case in refQualify so that:
- has() on a non-container, non-optional type (presenceOnly=true):
returns missingKey error, preventing silent false returns
- has() on an optional value (e.g. optional.none()): continues to
return false, preserving correct optional semantics
- Optional field selection (x.?field, presenceOnly=false): continues
to return not-present for optional.none() compatibility
- EnableErrorOnBadPresenceTest(true): errors for all cases (unchanged)
No test expectations changed. Full suite green.
Signed-off-by: Koda Reef <koda.reef5@gmail.com>1 parent d942970 commit 84f0136
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1419 | 1419 | | |
1420 | 1420 | | |
1421 | 1421 | | |
1422 | | - | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
1423 | 1430 | | |
1424 | 1431 | | |
1425 | 1432 | | |
| |||
0 commit comments