Skip to content

feat(ingest): match messages in custom inbound filter#116701

Merged
oioki merged 1 commit into
masterfrom
feat/inbound-filter-match-messages
Jun 2, 2026
Merged

feat(ingest): match messages in custom inbound filter#116701
oioki merged 1 commit into
masterfrom
feat/inbound-filter-match-messages

Conversation

@oioki

@oioki oioki commented Jun 2, 2026

Copy link
Copy Markdown
Member

Extend the custom-error generic inbound filter to also match capture_message events, not just exceptions.

The condition built by _error_message_condition only ever inspected event.exception.values, globbing each exception's type and message. Message events (capture_message) carry no exception interface — their text lands at event.logentry.formatted after normalization — so they slipped past the filter entirely.

This adds an opt-in match_logentry flag to _error_message_condition. When set, type-less patterns (None, message) additionally glob event.logentry.formatted, and the result is wrapped in a top-level or of the exception branch and the message branches. _custom_error_filter enables it; the built-in chunk-load-error and react-hydration-errors filters keep the default (match_logentry=False), so their generated Relay config is byte-for-byte unchanged.

A logentry message has no exception type, so only type-less patterns can match a message — patterns that carry a type stay exception-only. When no type-less pattern is configured, the condition collapses back to the original exception-only shape (no empty or wrapper).

Note: tests assert the generated RuleCondition structure and simulate glob matching locally; they do not exercise real Relay evaluation of event.logentry.formatted. That field is the canonical normalized message path used elsewhere in Sentry (grouping, json pruning), so the name is correct, but full end-to-end confirmation would require sending a message event through Relay with the filter configured.

The custom-error generic filter only inspected `event.exception.values`, so
events captured via `capture_message` (which carry no exception interface)
were never filtered. Extend `_error_message_condition` with an opt-in
`match_logentry` flag that also globs type-less patterns against
`event.logentry.formatted`, and enable it for `_custom_error_filter`.

A logentry message has no exception type, so only type-less patterns
`(None, message)` apply to messages; patterns carrying a type stay
exception-only. The built-in chunk-load and hydration filters keep
`match_logentry=False`, so their generated config is unchanged.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 2, 2026
@oioki oioki requested a review from untitaker June 2, 2026 16:49
@oioki oioki marked this pull request as ready for review June 2, 2026 16:49
@oioki oioki requested a review from a team as a code owner June 2, 2026 16:49
@oioki oioki merged commit 27a339d into master Jun 2, 2026
68 of 69 checks passed
@oioki oioki deleted the feat/inbound-filter-match-messages branch June 2, 2026 17:56
Comment on lines +338 to +340
message_conditions.append(
{"op": "glob", "name": "event.logentry.formatted", "value": [value]}
)

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.

We might also want to check event.logentry.message to match how relay implements legacy error messages: https://github.com/getsentry/relay/blob/f1b7447625d4e9f692c972c36bd6690e32c6ddce/relay-filter/src/error_messages.rs#L15-L23

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