Skip to content

feat: support generic entity instance in selectors#6321

Merged
evankanderson merged 5 commits intomindersec:mainfrom
Jaydeep869:issue-5380-generic-entity-selectors
Apr 12, 2026
Merged

feat: support generic entity instance in selectors#6321
evankanderson merged 5 commits intomindersec:mainfrom
Jaydeep869:issue-5380-generic-entity-selectors

Conversation

@Jaydeep869
Copy link
Copy Markdown
Contributor

Summary

This PR adds complete support for generic entity instances within selectors.

Previously, if a selector was added to an unmapped entity (like release or build), the evaluation failed with a No converter available error because newConverter in selector_entity.go relied on a strict switch statement covering only repository, artifact, and pull_request. While PR #5379 introduced the generic environment fallback, newConverter still returned nil for unsupported entities.

This change introduces a genericToSelectorEntity fallback in the converter factory, populating a new SelectorGeneric protobuf message that dynamically exposes all the entity properties. This ensures that properties for generalized entities correctly pipe into CEL environments without breaking.

Fixes #5380

Testing

  • Added SelectorGeneric to internal/proto/internal.proto and regenerated the protobuf definitions using make buf.
  • Created a "Generic Entity Type" test case in internal/providers/selectors/selector_entity_test.go to ensure unmapped objects successfully populate their properties map through the generic constructor.
  • Added an integration scenario "Simple true generic release expression" in pkg/engine/selectors/selectors_test.go to verify that CEL expressions correctly evaluate fields on generic entities (e.g., generic.name == 'testorg/testrelease').
  • Executed make test locally to confirm all suite assertions pass successfully.
  • including regressions pass cleanly. Run successfully.
  • Executed make lint and go fmt to ensure compliance with styling guidelines.

@Jaydeep869 Jaydeep869 requested a review from a team as a code owner April 9, 2026 20:09
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

Fixes mindersec#5380

Supports dynamically creating CEL environments and exposing
properties for unmapped entities (like Release or Build). This fully
unblocks entity evaluators that were previously returning nil for
unsupported entity types, utilizing the generic Property structures
instead.

Signed-off-by: Your Name <your.email@example.com>
Signed-off-by: jaydeep869 <jaydeeppokhariya2106@gmail.com>
@Jaydeep869 Jaydeep869 force-pushed the issue-5380-generic-entity-selectors branch from ad7aa8d to 7f3fec4 Compare April 9, 2026 20:12
@evankanderson
Copy link
Copy Markdown
Member

(will look tomorrow, it's getting late)

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 10, 2026

Coverage Status

Coverage is 59.391%Jaydeep869:issue-5380-generic-entity-selectors into mindersec:main. No base build found for mindersec:main.

Copy link
Copy Markdown
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need some manual integration testing to ensure that the selector actually works in a Profile?

Comment thread internal/proto/internal.proto Outdated
Comment thread internal/providers/selectors/selector_entity_test.go
@Jaydeep869
Copy link
Copy Markdown
Contributor Author

Does this need some manual integration testing to ensure that the selector actually works in a Profile?

@evankanderson There is an automated integration test in selectors_test.go ('Simple true generic release expression') that evaluates an end to end CEL environment condition successfully matching a generic ENTITY_RELEASE payload. This verifies the selector correctly works within a profile context directly inside the engine evaluation boundary. I can also do a localized manual run if you'd like an extra sanity check!

Signed-off-by: jaydeep869 <jaydeeppokhariya2106@gmail.com>
@Jaydeep869 Jaydeep869 force-pushed the issue-5380-generic-entity-selectors branch from a081a13 to 8c76b91 Compare April 11, 2026 13:15
@evankanderson
Copy link
Copy Markdown
Member

Does this need some manual integration testing to ensure that the selector actually works in a Profile?

@evankanderson There is an automated integration test in selectors_test.go ('Simple true generic release expression') that evaluates an end to end CEL environment condition successfully matching a generic ENTITY_RELEASE payload. This verifies the selector correctly works within a profile context directly inside the engine evaluation boundary. I can also do a localized manual run if you'd like an extra sanity check!

Generally, for changes that are intended to be user-visible, it's a good idea to run a manual test of the functionality unless there's a non-mocked integration test (I often use grpcurl or curl and the grpc-gateway for API changes, and check the database for manual changes). Unfortunately, it's easy to get convinced about the full behavior of the system when you're looking at a small targeted change, and miss the implications in other parts of the code (e.g. "the client prevents this" or "layer X needs corresponding changes").

@evankanderson
Copy link
Copy Markdown
Member

Additionally, doing a manual check can help with getting examples to update documentation. 😁

@Jaydeep869
Copy link
Copy Markdown
Contributor Author

@evankanderson I just ran through a manual end to end check using a local Minder instance. I created a profile with a release selector using the CLI, and the API accepted it perfectly. The engine evaluation worked correctly without any plumbing layers or client filters getting in the way.

Taking your advice, I've also just pushed a small documentation update to profile_selectors.md to include a working CEL example and the available generic properties so users know exactly how to write selectors for these new unmapped entities.

@evankanderson evankanderson merged commit d37e0c2 into mindersec:main Apr 12, 2026
27 checks passed
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.

Support generic entity instance in selectors

4 participants