Skip to content

bundle: improve determinism of file_rego_versions patterns with overlap.#8733

Open
philipaconrad wants to merge 1 commit into
open-policy-agent:mainfrom
philipaconrad:philip/file_rego_versions-lexical-sort
Open

bundle: improve determinism of file_rego_versions patterns with overlap.#8733
philipaconrad wants to merge 1 commit into
open-policy-agent:mainfrom
philipaconrad:philip/file_rego_versions-lexical-sort

Conversation

@philipaconrad
Copy link
Copy Markdown
Member

What code changed, and why?

This PR makes the behavior of pattern selection for file_rego_versions from a bundle manifest more deterministic when the patterns have overlap.

The Bundle docs note that when overlapping patterns occur, the result is undefined. In practice, this meant that the map of patterns was iterated over in randomized order.

We now iterate over the file_rego_version patterns in lexically-sorted order, which ensures a deterministic result, even when user-authored glob patterns overlap with each other.

This turned up when I was looking into making bundle builds reproducible, and while it's an uncommon edge case, it's still an edge case where two runs could produce different results.

How to test?

  • A new regression test was added under v1/bundle.

This commit makes the behavior of pattern selection for
determining file rego versions from a bundle manifest more
deterministic when the pattern have overlap.

The docs note that when overlapping patterns occur, the result
is undefined. In practice, this meant that the map of patterns
was iterated over in randomized order.

We now iterate over the `file_rego_version` patterns in
lexically-sorted order, which ensures a deterministic result,
even when user-authored glob patterns overlap with each other.

Signed-off-by: Philip Conrad <philip_conrad@apple.com>
@philipaconrad philipaconrad self-assigned this Jun 3, 2026
@philipaconrad philipaconrad removed their assignment Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant