Repository navigation
fix(cli): Use the issues endpoint's filtered counts for release: queries - #1590
Merged
Merged
Conversation
`issue list --query 'release:"X"'` fixed its displayed counts in #1512 by refetching each listed issue's counts from the events endpoint after the listing was built. Multi-project listings merge and trim to `--limit` before that step, so `--sort freq`/`--sort user` picked rows using period-wide counts and could drop the issues that matter for the release. The issues endpoint already computes counts scoped to the query's event-level filters in its `filtered` block. The CLI always collapsed it. Request `filtered` (and keep `stats`, which the server nests it under) when the query has a `release:` filter. Promote those counts into `count`/`userCount` right after each fetch, before any merge, sort, or trim. This also removes the per-issue events fan-out (`issue-scoped-counts.ts`). Refs #1583 Co-Authored-By: Burak Yigit Kaya <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
BYK
approved these changes
Oct 22, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1512 and #1583.
#1512 fixed the counts
sentry issue list --query 'release:"X"'displays: after building the listing, it refetches each issue's counts from the events endpoint. But in multi-project listings (DSN auto-detect, project search across orgs), the CLI merges the per-project results and trims them to--limitbefore that refetch runs. So--sort freq/--sort userpicked the rows using period-wide counts. That could drop the issues with the most events in the release and keep ones that barely appear in it. The re-ranking afterwards only reorders rows that already survived the trim.Root cause. The issues endpoint already returns release-scoped counts.
StreamGroupSerializerSnubabuilds conditions from the query's event-level search filters, andreleaseisn't inskip_snuba_fields. Whenfilteredisn't collapsed, it returnsfiltered.count/filtered.userCountcomputed with those conditions. The search executor'sfreq/usersort aggregates over the same filtered events. So each server page is already ordered by release-scoped counts. The CLI just never read those numbers, becausebuildIssueListCollapsealways collapsedfiltered.Sentry sources checked:
src/sentry/api/serializers/models/group_stream.py,group.py(GroupSerializerSnuba.__init__,SKIP_SNUBA_FIELDS), andsrc/sentry/search/snuba/executors.py(sort_strategies,aggregation_defs).Change
buildIssueListCollapsegainsshouldCollapseFiltered. It defaults totrue, so other callers likefeedbackare unchanged.shouldScopeCountsis true (arelease:filter, and the counts are shown or drive the sort),issue liststops collapsingfiltered. It also keepsstats, because the server only returnsfilteredwhen stats aren't collapsed.applyQueryScopedCountscopiesfiltered.count/filtered.userCountintocount/userCountright after each fetch: per target, org-wide, and cursor resume. That happens before any merge, sort, or trim. It then dropsfiltered, so the--jsonoutput shape doesn't change.issue-scoped-counts.ts,applyScopedCounts, and theprojectoption onExploreQueryOptionsthat only it used). That's one fewer request per listed issue.Tests
test/commands/issue/list.test.ts:release:filteredcounts promoted intocount/userCount, andfiltered: nullfalling back to the top-level counts--sort freq --fields id,titlekeeping stats--sort freq --limit 2merge/trim regression testmain(4 of 5; the no-release case passes either way) and pass with this change.test/lib/issue-collapse.property.test.ts: a property test forshouldCollapseFiltered.Verification
tsc --noEmitandpnpm run lint(oxlint + oxfmt): clean.pnpm run test:unit: 11188 passed and 6 failed. All 6 failures are permission tests (EACCES/EPERM, read-only DB, unreadable files) incompletions,telemetry,upgrade,code-scanner, andfile-changes. The same 6 fail on unmodifiedmainin this sandbox.via BYK.
--
View Junior Session [Sentry]