Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/engine/selectors/selectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,24 @@ func (s *EntitySelection) Select(se *internalpb.SelectorEntity, userOpts ...Sele
// check unknowns /before/ an error. Maybe we should try to special-case the one
// error we get from the CEL library in this case and check for the rest?
if s.detailHasUnknowns(sel, details) {
return false, "", ErrResultUnknown
if len(opts.unknownPaths) > 0 {
// Explicit unknown paths were set by the caller (via WithUnknownPaths), meaning
// the caller is doing a first-pass evaluation with intentionally incomplete data
// and expects to retry with more information. Signal this intent.
return false, "", ErrResultUnknown
}
// No explicit unknown paths: the entity simply does not have this property.
// Properties are not guaranteed to exist, so proceed with evaluation.
return true, "", nil
}

if err != nil {
return false, "", fmt.Errorf("failed to evaluate Expression: %w", err)
}

if types.IsUnknown(out) {
return false, "", ErrResultUnknown
// The property is missing from the entity data; proceed with evaluation.
return true, "", nil
}

if out.Type() != cel.BoolType {
Expand Down
11 changes: 6 additions & 5 deletions pkg/engine/selectors/selectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ func TestSelectSelectorEntity(t *testing.T) {
"github": map[string]any{"is_fork": true},
}),
),
expectedSelectErr: ErrResultUnknown,
selected: false,
// Missing property: entity is selected so evaluation can proceed
selected: true,
},
{
name: "Attempt to use a property while having nil properties",
Expand All @@ -658,8 +658,8 @@ func TestSelectSelectorEntity(t *testing.T) {
},
},
selectorEntityBld: newTestRepoSelectorEntity(newGithubProviderSelector()),
expectedSelectErr: ErrResultUnknown,
selected: false,
// Missing property: entity is selected so evaluation can proceed
selected: true,
},
{
name: "The selector shortcuts if evaluation is not needed for properties",
Expand Down Expand Up @@ -947,7 +947,8 @@ func TestSelectorEntityFillProperties(t *testing.T) {
},
}}
},
secondSucceeds: false,
// property is missing, entity is selected so evaluation can proceed
secondSucceeds: true,
},
}

Expand Down
Loading