Skip to content

Improved redundant-existence-check#1897

Merged
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:redundant-existence-check-fix
Feb 26, 2026
Merged

Improved redundant-existence-check#1897
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:redundant-existence-check-fix

Conversation

@anderseknert
Copy link
Copy Markdown
Member

By looking in both directions. Still not exhaustive, but that's way too expensive.. and most redundant checks are adjacent to the place of use.

Fixes #1805

@charlieegan3
Copy link
Copy Markdown
Contributor

I guess the look ahead behind could be configurable.

@charlieegan3 charlieegan3 added this pull request to the merge queue Feb 26, 2026
@charlieegan3 charlieegan3 removed this pull request from the merge queue due to the queue being cleared Feb 26, 2026
@charlieegan3 charlieegan3 added this pull request to the merge queue Feb 26, 2026
@charlieegan3 charlieegan3 force-pushed the redundant-existence-check-fix branch from 254249d to 5f4b36b Compare February 26, 2026 12:06
@charlieegan3 charlieegan3 removed this pull request from the merge queue due to the queue being cleared Feb 26, 2026
By looking in both directions. Still not exhaustive, but that's
way too expensive.. and most redundant checks are adjacent to
the place of use.

Fixes open-policy-agent#1805

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
@anderseknert anderseknert force-pushed the redundant-existence-check-fix branch from 5f4b36b to 623f02c Compare February 26, 2026 12:20
@anderseknert
Copy link
Copy Markdown
Member Author

@charlieegan3 yes, but what if you find:

foo.bar
super_expensive_call()
foo.bar.baz == 1

Is the foo.bar check redundant? Logically yes it is, as the rule will evaluate the same without it. But it’s also a reasonable way to guard the more expensive computation below, making it not redundant. Like a poor man’s indexer. That’s why being exhaustive here is next to impossible 😅

@anderseknert anderseknert merged commit f2c03e5 into open-policy-agent:main Feb 26, 2026
8 checks passed
@anderseknert anderseknert deleted the redundant-existence-check-fix branch February 26, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make redundant-existence-check care less about where a check happens

2 participants