fix(snuba): Handle direct project.id groupby in top event conditions#109535
Merged
fix(snuba): Handle direct project.id groupby in top event conditions#109535
Conversation
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>
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>
shruthilayaj
approved these changes
Mar 2, 2026
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.
Handle direct
project.idgroupby inbuild_top_event_conditionsWhen grouping by
project.iddirectly 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 whereproject.idappeared as a derived groupby key (from grouping byprojectorproject.name), where the data contains the slug under a"project"or"project.slug"key. This caused aKeyError: '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