Skip to content

Conversation

cmanallen
Copy link
Member

Prefixing ! before a pattern will negate the pattern that follows. This is designed for use within inbound-filters (specifically release filters) where a customer wants to define an allow-list (as opposed to the current deny-list).

@cmanallen cmanallen requested a review from a team as a code owner September 4, 2025 14:30
fn parse(&mut self) -> Result<(), ErrorKind> {
if self.advance_if(|c| c == '!') {
self.push_token(Token::Negated);
};
Copy link

Choose a reason for hiding this comment

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

Bug: Negated Token Incorrectly Affects Wildmatch

The Token::Negated is incorrectly passed into the wildmatch algorithm. This meta-token should be stripped before wildmatch evaluation, as its inclusion causes incorrect matching, especially for patterns like ! which incorrectly match non-empty strings but not empty ones.

Additional Locations (2)

Fix in Cursor Fix in Web

@jjbayer
Copy link
Member

jjbayer commented Sep 5, 2025

@cmanallen have you considered using Generic Inbound Filters for this? We consider the other inbound filters as deprecated and would prefer if new features are implemented through generic filters instead.

@cmanallen cmanallen requested a review from Dav1dde September 16, 2025 13:27

- Add InstallableBuild and SizeAnalysis data categories. ([#5084](https://github.com/getsentry/relay/pull/5084))
- Add dynamic PII derivation to `metastructure`. ([#5107](https://github.com/getsentry/relay/pull/5107))
- Add negation pattern matching. ([#5116](https://github.com/getsentry/relay/pull/5116))
Copy link
Member

Choose a reason for hiding this comment

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

Wrong section now.

Comment on lines +371 to +372
/// The pattern is complex and needs to be evaluated using [`wildmatch`].
NegatedWildmatch(Tokens),
Copy link
Member

Choose a reason for hiding this comment

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

That doesn't seem correct, a Static literal can also be inverted, we now have this implicit behavior of negated is always a wild match, which also removes a lot of the performance benefits we have by factoring out simple patterns.

You can instead track this property on the Pattern itself and just invert the is_match there.

Comment on lines +509 to +511
if self.advance_if(|c| c == '!') {
self.push_token(Token::Negated);
};
Copy link
Member

Choose a reason for hiding this comment

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

I think we should make this behavior configurable via Options and only enable it for releases for now.

We can then just use a TypedPattern with special options for that one glob.

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.

3 participants