Fix: proceed with evaluation when selector references an unknown entity property#6136
Fix: proceed with evaluation when selector references an unknown entity property#6136
Conversation
…property When a CEL selector expression references a property that doesn't exist on an entity, the selector previously returned ErrResultUnknown which propagated as "error selecting entity: result is unknown". The fix distinguishes between two scenarios: 1. WithUnknownPaths was explicitly set (retry pattern): still returns ErrResultUnknown to signal the caller to retry with more data. 2. No explicit unknown paths: the property is simply missing from the entity. Properties are not guaranteed to exist, so the entity is selected and evaluation proceeds (returns true, "", nil). Updated tests to reflect the new behavior where missing properties no longer block evaluation. Co-authored-by: evankanderson <7959095+evankanderson@users.noreply.github.com>
|
I need to think about what the correct behavior here is. Some example cases: |
|
There's an additional wrinkle that selectors apply to a specific type of entity (as shown in the documentation). From reading the code, it appears that all selectors for the appropriate entity type must currently succeed for the rule to be evaluated; if any selector fails or is unknown, then the rule evaluation is skipped. It seems like a disjunctive normal form for the list (OR of ANDs) might make more sense, so an entity is selected if at least one selector passes. That's a larger change, though. |
|
This PR needs additional information before we can continue. It is now marked as stale because it has been open for 30 days with no activity. Please provide the necessary details to continue or it will be closed in 30 days. |
|
|
Using a property that doesn't exist in a profile selector (e.g.,
repository.properties.github['is_private']) caused a hard error:error evaluating rule type: error selecting entity: result is unknown. Properties are not guaranteed to be present, so evaluation should proceed rather than error.Changes
pkg/engine/selectors/selectors.goThe
Select()method now distinguishes two "unknown result" scenarios:WithUnknownPathsexplicitly set — caller is in the first pass of a retry pattern;ErrResultUnknownis still returned to trigger a retry with complete data.(true, "", nil)so evaluation proceeds.The same logic applies to the
types.IsUnknown(out)fallback check.pkg/engine/selectors/selectors_test.goErrResultUnknownfor missing properties (noWithUnknownPaths) updated to expectselected: true.TestSelectorEntityFillProperties"Fail to fetch a property" case updated: a property that can't be fetched no longer blocks evaluation (secondSucceeds: true).Testing
Unit tests in
pkg/engine/selectors/selectors_test.gocover the updated behavior directly. All selector and executor tests pass. TheWithUnknownPathsretry-pattern tests remain unchanged and continue to returnErrResultUnknownas expected.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.google.com/tmp/go-build3711714686/b1939/rego.test /tmp/go-build3711714686/b1939/rego.test -test.testlogfile=/tmp/go-build3711714686/b1939/testlog.txt -test.paniconexit0 -test.timeout=2m0s -o 1714686/b1867/_p-errorsas mpile ux-amd64/pkg/tool/linux_amd64/vet -p .io/otel/semconv--64 t ux-amd64/pkg/too/tmp/ccPlXZWt.o -o E1mN/pSRwwy3Gpf6wksvjE1mN t ux-amd64/pkg/tool/linux_amd64/vet -p github.com/open--quiet t ux-amd64/pkg/toox86_64-linux-gnu(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Error: error evaluating rule type: error selecting entity: result is unknown#4785🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.