Skip to content

fix(search-issues): Report counts that match the query's event filters - #2140

Draft
sentry-junior[bot] wants to merge 1 commit into
mainfrom
fix/search-issues-filtered-counts
Draft

sentry-junior[bot] wants to merge 1 commit into
mainfrom
fix/search-issues-filtered-counts

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

search_issues uses each issue's top-level count / userCount for occurrences / usersImpacted (results.ts:148 on main). Sentry computes those top-level counts from the time range and the environment URL parameter only. Event filters in the query string, such as environment:production, are not applied. The issues endpoint returns the counts that do apply them in filtered.count / filtered.userCount. That field is documented as "events that match the search query" and is null when the query has no such filters.

Sentry source (getsentry/sentry src/sentry/api/serializers/models/group_stream.py): __seen_stats_impl (L871) runs the time-range query with environment_ids only, and runs it again with conditions=self.conditions (L891) to fill filtered (L776-789).

User feedback reported search_issues occurrences that didn't match an environment-filtered search_errors aggregate for the same issue and window. Traces showed the serializer running both seen-stats queries, one without the environment condition and one with it, and MCP reporting the unfiltered one.

Change

  • IssueSchema gains an optional, nullable filtered: {count, userCount}.
  • buildIssueResults prefers filtered counts when Sentry returns them, and otherwise falls back to the top-level counts.

listIssues only collapses unhandled, so filtered is already in the response. The CLI made the same change for release: queries in #1590.

via @sergical.

--

View Session [Sentry]

search_issues reported each issue's top-level count as occurrences.
Sentry computes that count over the time range and the environment URL
parameter only, so event filters in the query string, such as
environment:production, are not applied. The issues endpoint returns
those filtered counts in filtered.count and filtered.userCount
(StreamGroupSerializerSnuba in getsentry/sentry).

Prefer the filtered counts when Sentry returns them, so occurrences and
usersImpacted match the query the caller ran.

Co-Authored-By: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 10, 2026 12:20pm UTC

Request Review

This branch was successfully deployed

1 active and 1 inactive deployments
Actions — daab5f5b Deployed Nov 10, 2026 by sentry-junior[bot] via eval #1770
Preview — daab5f5b Deployed Nov 10, 2026 by vercel[bot]
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.

1 participant