Skip to content

fix(search): Accept both issue ID formats in issue: and issue.id: filters - #131272

Open
SaltGardenia wants to merge 6 commits into
getsentry:masterfrom
SaltGardenia:fix/issue-filter-both-formats
Open

SaltGardenia wants to merge 6 commits into
getsentry:masterfrom
SaltGardenia:fix/issue-filter-both-formats

Conversation

@SaltGardenia

Copy link
Copy Markdown

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 like issue:4567 failed the short-ID lookup with a 400 (Issue IDs do not exist: ['4567']).
  • issue.id: was a numeric key in the search parser, so issue.id:PROJECT-123 failed with Invalid number.

API and MCP clients that only have numeric issue IDs got 400s from issue: (the Sentry MCP server currently rewrites numeric issue: filters client-side to work around this).

Per the proposal in the issue, both filters now accept both formats:

issue: accepts numeric group IDs

  • src/sentry/search/events/datasets/discover.py _issue_filter_converter: numeric values become group IDs directly, short IDs still resolve via by_qualified_short_id_bulk.
  • src/sentry/search/events/filter.py format_search_filter legacy issue branch: 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 to group_id.

issue.id: accepts qualified short IDs

  • src/sentry/api/event_search.py: issue.id stays a numeric key (so issue.id:>X comparison semantics are unchanged), but _handle_basic_filter now passes short-id-shaped values through instead of raising Invalid 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 the group_id condition.
  • src/sentry/search/events/filter.py legacy issue.id converter + format_search_filter equality 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's issue.id QCallbackCondition resolves short IDs via by_qualified_short_id_bulk, scoped to the selected projects; unresolvable short IDs return no results (mirroring non-existent numeric IDs).

Testing

  • Added parser/converter tests in tests/sentry/search/events/test_filter.py (numeric issue:, short-id issue.id:, mixed IN lists, unresolvable short ID).
  • Added an EAP test in tests/sentry/search/eap/test_spans.py for issue:<numeric group id>.
  • Extended test_issue_id_filter in tests/snuba/search/test_backend.py with short-ID and out-of-scope-project cases.

Notes for reviewers

  • issue.id: with short IDs now resolves org-wide via project_ids=None in the event-search converters, matching the existing issue: behavior; the group search backend scopes to the selected projects since it has them available.
  • issue.id:4k style numeric suffixes (parse_numeric_value) remain supported since the key stays numeric.

…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
@SaltGardenia
SaltGardenia requested review from a team as code owners November 16, 2026 16:16
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 16, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread src/sentry/api/event_search.py Resolved
except Group.DoesNotExist:
pass
else:
group_ids.update(g.id for g in groups)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

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.

@cvxluo cvxluo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems like a dupe of #130944

This branch has not been deployed

No deployments
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.

Accept both issue ID formats in issue: and issue.id: filters

2 participants