Repository navigation
fix(search): Accept both issue ID formats in issue: and issue.id: filters - #131272
SaltGardenia wants to merge 6 commits into
Conversation
…ters Event search had two filters for the same thing, each accepting only one issue ID format: `issue:` only accepted qualified short IDs (PROJECT-123) while `issue.id:` only accepted numeric group IDs, so API and MCP clients passing numeric IDs to `issue:` got a 400. - `issue:` now also accepts numeric group IDs in the discover dataset, the legacy filter conversion path, and the EAP occurrences resolver. - `issue.id:` now also accepts qualified short IDs: the parser passes short-id-shaped values through the basic filter, the dataset/legacy converters resolve them to group IDs, and the group search backend resolves them scoped to the selected projects. Fixes getsentry#130940
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7bae148. Configure here.
| except Group.DoesNotExist: | ||
| pass | ||
| else: | ||
| group_ids.update(g.id for g in groups) |
There was a problem hiding this comment.
Invalid short ID drops valid matches
Medium Severity
_make_issue_id_filter swallows Group.DoesNotExist from the bulk short-id lookup and skips every short ID in the list. One unresolvable or out-of-scope short ID in an issue.id: IN list discards the valid ones too, instead of matching them the way leftover numeric IDs still match.
Reviewed by Cursor Bugbot for commit 7bae148. Configure here.
- Allow project slugs containing dashes in the issue.id short-id pattern (e.g. WEALTHY-WAHOO-1). - Sort resolved group ids so mixed numeric/short-id IN filters produce deterministic conditions regardless of input order. - Create the out-of-scope project in the backend short-id test instead of relying on a project2 attribute.


Fixes #130940
Summary
Event search has two filters for the same thing, and each only accepted one issue ID format:
issue:only accepted qualified short IDs (PROJECT-123); a numeric group ID likeissue:4567failed the short-ID lookup with a 400 (Issue IDs do not exist: ['4567']).issue.id:was a numeric key in the search parser, soissue.id:PROJECT-123failed withInvalid number.API and MCP clients that only have numeric issue IDs got 400s from
issue:(the Sentry MCP server currently rewrites numericissue:filters client-side to work around this).Per the proposal in the issue, both filters now accept both formats:
issue:accepts numeric group IDssrc/sentry/search/events/datasets/discover.py_issue_filter_converter: numeric values become group IDs directly, short IDs still resolve viaby_qualified_short_id_bulk.src/sentry/search/events/filter.pyformat_search_filterlegacyissuebranch: same split.src/sentry/search/eap/resolver.py_init_issue_short_id_cache+src/sentry/search/eap/occurrences/filter_aliases.py_get_group_ids: numeric values skip the Group lookup and map straight togroup_id.issue.id:accepts qualified short IDssrc/sentry/api/event_search.py:issue.idstays a numeric key (soissue.id:>Xcomparison semantics are unchanged), but_handle_basic_filternow passes short-id-shaped values through instead of raisingInvalid number. Junk values still raise the original error.src/sentry/search/events/datasets/discover.py_issue_id_filter_converter: resolves short IDs against the organization and coerces numeric strings to ints for thegroup_idcondition.src/sentry/search/events/filter.pylegacyissue.idconverter +format_search_filterequality branch: same resolution (the equality branch narrows the postgres queryset, so short IDs must be resolved to real group IDs there).src/sentry/search/snuba/backend.py: the group search backend'sissue.idQCallbackConditionresolves short IDs viaby_qualified_short_id_bulk, scoped to the selected projects; unresolvable short IDs return no results (mirroring non-existent numeric IDs).Testing
tests/sentry/search/events/test_filter.py(numericissue:, short-idissue.id:, mixed IN lists, unresolvable short ID).tests/sentry/search/eap/test_spans.pyforissue:<numeric group id>.test_issue_id_filterintests/snuba/search/test_backend.pywith short-ID and out-of-scope-project cases.Notes for reviewers
issue.id:with short IDs now resolves org-wide viaproject_ids=Nonein the event-search converters, matching the existingissue:behavior; the group search backend scopes to the selected projects since it has them available.issue.id:4kstyle numeric suffixes (parse_numeric_value) remain supported since the key stays numeric.