chore(flagpole-wildcard-ops): Adding support for not_matches op (python)#115901
Merged
Conversation
wedamija
approved these changes
May 20, 2026
JonasBa
pushed a commit
that referenced
this pull request
May 21, 2026
…on) (#115901) Notes: - In par with sentry-options: getsentry/sentry-options#127 - Task documentation: [link](https://www.notion.so/sentry/Adding-wildcard-support-to-flagpole-condition-operators-3598b10e4b5d819e8c16e207ee3a4349) - Test Duplication: Unlike simpler pairs like in/not_in, glob matching has enough edge cases (overlapping anchors, multi-segment wildcards, case folding) that explicit mirrored coverage is worth it. Adds a new `not_matches` condition operator that accepts a list of glob patterns and returns true if the context property value matches none of them. Reuses the existing `_glob_star_match` helper and `_evaluate_matches` shared method introduced for matches. Changes: `src/flagpole/conditions.py` — adds NOT_MATCHES to `ConditionOperatorKind`, refactors `MatchesCondition._operator_match` into a shared _evaluate_matches method on `ConditionBase`, adds `NotMatchesCondition` class (returns not `self._evaluate_matches(...)`), and registers it in `OPERATOR_LOOKUP`. `src/flagpole/flagpole-schema.json` — adds `NotMatchesCondition` definition and registers it in the `Segment.conditions` discriminator and `oneOf`. `src/sentry/runner/commands/createflag.py` — adds `NOT_MATCHES` to the set of operators that initialize value as a list in the condition wizard. `tests/flagpole/test_conditions.py` — adds `TestNotMatchesConditions` mirroring all TestMatchesConditions cases with inverted assertions: literal match, prefix wildcard, prefix+suffix wildcard, suffix wildcard, multi-star wildcard, star-only pattern, case insensitivity, no-match, multiple patterns, overlapping prefix/suffix anchor guard, and type mismatch errors for list/dict context properties.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notes:
Adds a new
not_matchescondition operator that accepts a list of glob patterns and returns true if the context property value matches none of them. Reuses the existing_glob_star_matchhelper and_evaluate_matchesshared method introduced for matches.Changes:
src/flagpole/conditions.py— adds NOT_MATCHES toConditionOperatorKind, refactorsMatchesCondition._operator_matchinto a shared _evaluate_matches method onConditionBase, addsNotMatchesConditionclass (returns notself._evaluate_matches(...)), and registers it inOPERATOR_LOOKUP.src/flagpole/flagpole-schema.json— addsNotMatchesConditiondefinition and registers it in theSegment.conditionsdiscriminator andoneOf.src/sentry/runner/commands/createflag.py— addsNOT_MATCHESto the set of operators that initialize value as a list in the condition wizard.tests/flagpole/test_conditions.py— addsTestNotMatchesConditionsmirroring all TestMatchesConditions cases with inverted assertions: literal match, prefix wildcard, prefix+suffix wildcard, suffix wildcard, multi-star wildcard, star-only pattern, case insensitivity, no-match, multiple patterns, overlapping prefix/suffix anchor guard, and type mismatch errors for list/dict context properties.