Skip to content

fix(snuba): Handle direct project.id groupby in top event conditions#109535

Merged
Zylphrex merged 2 commits intomasterfrom
txiao/fix/group-by-project-id-in-events-timeseries
Mar 2, 2026
Merged

fix(snuba): Handle direct project.id groupby in top event conditions#109535
Zylphrex merged 2 commits intomasterfrom
txiao/fix/group-by-project-id-in-events-timeseries

Conversation

@Zylphrex
Copy link
Member

@Zylphrex Zylphrex commented Feb 26, 2026

Handle direct project.id groupby in build_top_event_conditions

When grouping by project.id directly in the timeseries spans endpoint, the top events query returns data keyed by "project.id" with the integer project ID as value. The existing code only handled the case where project.id appeared as a derived groupby key (from grouping by project or project.name), where the data contains the slug under a "project" or "project.slug" key. This caused a KeyError: 'project.slug'.

The fix checks if the event data already has a "project.id" key and uses the value directly, falling back to the slug-based lookup for the derived case.

Fixes SENTRY-5KF8

When grouping by `project.id` directly, the top events query returns
data keyed by `project.id` with the integer ID as value. Previously
the code only handled the case where the data was keyed by `project`
or `project.slug` (from grouping by project name), causing a KeyError.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 26, 2026
Verify that grouping by `project.id` directly in the timeseries spans
endpoint returns correct results without raising a KeyError.

Co-Authored-By: Claude <noreply@anthropic.com>
@Zylphrex Zylphrex marked this pull request as ready for review February 26, 2026 22:54
@Zylphrex Zylphrex requested a review from a team as a code owner February 26, 2026 22:54
@Zylphrex Zylphrex merged commit c92cdeb into master Mar 2, 2026
62 checks passed
@Zylphrex Zylphrex deleted the txiao/fix/group-by-project-id-in-events-timeseries branch March 2, 2026 17:39
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.

2 participants