Skip to content

chore(flagpole-wildcard-op): Implementing 'matches' as a flagpole con…#115385

Merged
Abdkhan14 merged 5 commits into
masterfrom
abdk/flagpole-matches-m1
May 13, 2026
Merged

chore(flagpole-wildcard-op): Implementing 'matches' as a flagpole con…#115385
Abdkhan14 merged 5 commits into
masterfrom
abdk/flagpole-matches-m1

Conversation

@Abdkhan14
Copy link
Copy Markdown
Contributor

@Abdkhan14 Abdkhan14 commented May 12, 2026

NOTES:

Adds a new matches condition operator that accepts a list of glob patterns and returns true if the context property value matches any of them. Patterns support * as a wildcard (zero or more characters); all other characters are treated literally.

Changes:

src/flagpole/conditions.py — adds MATCHES to ConditionOperatorKind, _glob_star_match helper (hand-rolled split-and-scan, no new dependencies), MatchesCondition class, and registers it in OPERATOR_LOOKUP.

src/flagpole/flagpole-schema.json — adds MatchesCondition definition and registers it in the Segment.conditions discriminator and oneOf.

tests/flagpole/test_conditions.py — adds TestMatchesConditions covering: literal match, prefix wildcard (jayonb*), prefix+suffix wildcard (jay.goss+onboarding*@sentry.io), suffix wildcard (@sentry.io), multi-star wildcard (ab*c), star-only pattern, case insensitivity, no-match, multiple patterns in one condition, and type mismatch errors for list/dict context properties.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 12, 2026
@Abdkhan14 Abdkhan14 marked this pull request as ready for review May 12, 2026 18:46
@Abdkhan14 Abdkhan14 requested review from a team as code owners May 12, 2026 18:46
Comment thread src/flagpole/conditions.py
Comment thread src/flagpole/conditions.py
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 57aa280. Configure here.

Comment thread tests/sentry/runner/commands/test_createflag.py
)


def _glob_star_match(pattern: str, value: str) -> bool:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason we don't use glob_match instead of this custom function?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Longer term, we need the same behavior in both the current python implementation (this change), and in sentry-options. Using a more fully feature glob implementation is ok if we can have the same behavior across the python/rust implementations.

Copy link
Copy Markdown
Member

@wedamija wedamija May 12, 2026

Choose a reason for hiding this comment

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

glob_match implemented in rust in sentry-relay, so possibly there's a way we can share this logic between both systems at some point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree — longer term there's a path to aligning with relay's glob implementation if it ever becomes a shared crate. For now, moving forward with this hand-rolled star-only impl since it's easy to verify for cross-language parity and covers our use case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That could work well. I'm hoping to not have the python implementation by the end of this year.

Copy link
Copy Markdown
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Looks good to me. I cross-checked against the Rust implementation.

)


def _glob_star_match(pattern: str, value: str) -> bool:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Longer term, we need the same behavior in both the current python implementation (this change), and in sentry-options. Using a more fully feature glob implementation is ok if we can have the same behavior across the python/rust implementations.

@Abdkhan14 Abdkhan14 merged commit 5a8ebd2 into master May 13, 2026
63 checks passed
@Abdkhan14 Abdkhan14 deleted the abdk/flagpole-matches-m1 branch May 13, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants