Skip to content

fix(cli): Use the issues endpoint's filtered counts for release: queries - #1590

Merged
BYK merged 1 commit into
mainfrom
fix/issue-list-filtered-counts
Oct 22, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/issue-list-filtered-counts

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

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 --limit before that refetch runs. So --sort freq / --sort user picked 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. StreamGroupSerializerSnuba builds conditions from the query's event-level search filters, and release isn't in skip_snuba_fields. When filtered isn't collapsed, it returns filtered.count / filtered.userCount computed with those conditions. The search executor's freq/user sort aggregates over the same filtered events. So each server page is already ordered by release-scoped counts. The CLI just never read those numbers, because buildIssueListCollapse always collapsed filtered.

Sentry sources checked: src/sentry/api/serializers/models/group_stream.py, group.py (GroupSerializerSnuba.__init__, SKIP_SNUBA_FIELDS), and src/sentry/search/snuba/executors.py (sort_strategies, aggregation_defs).

Change

  • buildIssueListCollapse gains shouldCollapseFiltered. It defaults to true, so other callers like feedback are unchanged.
  • When shouldScopeCounts is true (a release: filter, and the counts are shown or drive the sort), issue list stops collapsing filtered. It also keeps stats, because the server only returns filtered when stats aren't collapsed.
  • applyQueryScopedCounts copies filtered.count/filtered.userCount into count/userCount right after each fetch: per target, org-wide, and cursor resume. That happens before any merge, sort, or trim. It then drops filtered, so the --json output shape doesn't change.
  • Removes the per-issue events fan-out (issue-scoped-counts.ts, applyScopedCounts, and the project option on ExploreQueryOptions that only it used). That's one fewer request per listed issue.

Tests

  • test/commands/issue/list.test.ts:
    • collapse params with and without release:
    • filtered counts promoted into count/userCount, and filtered: null falling back to the top-level counts
    • --sort freq --fields id,title keeping stats
    • a multi-project --sort freq --limit 2 merge/trim regression test
  • The new tests fail on main (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 for shouldCollapseFiltered.

Verification

  • tsc --noEmit and pnpm 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) in completions, telemetry, upgrade, code-scanner, and file-changes. The same 6 fail on unmodified main in this sandbox.
  • Not run: e2e tests and a live API check against a real org.

via BYK.

--

View Junior Session [Sentry]

`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>
@vercel

vercel Bot commented Oct 22, 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 Oct 22, 2026 10:57am UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 22, 2026
@BYK
BYK merged commit e983cc0 into main Oct 22, 2026
26 checks passed
@BYK
BYK deleted the fix/issue-list-filtered-counts branch October 22, 2026 11:20

This branch was previously deployed

1 inactive deployment
Preview — 251fec4c Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant