fix(supergroups): Filter resolved groups from Seer response#112403
Merged
fix(supergroups): Filter resolved groups from Seer response#112403
Conversation
The status filter was pre-filtering group IDs sent to Seer, but Seer returns all group_ids per supergroup regardless of what was requested. So the response still contained resolved groups. Move the filtering to the response side - collect all group_ids Seer returns, query their actual status, and strip out non-matching ones. Also fixes the response key from "supergroups" to "data" to match the actual Seer response model (GetSupergroupsByGroupIdsResponse). The previous code was silently a no-op. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f98cb9e to
b6092c4
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Inconsistent defensive access causes KeyError on malformed response
- The list comprehension now uses
data.get("data", [])like the preceding loops, so missingdatasetsdata["data"]to[]instead of raising KeyError.
- The list comprehension now uses
Or push these changes by commenting:
@cursor push e0706bb469
Preview (e0706bb469)
diff --git a/src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py b/src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py
--- a/src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py
+++ b/src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py
@@ -112,6 +112,6 @@
for sg in data.get("data", []):
sg["group_ids"] = [gid for gid in sg["group_ids"] if gid in matching_ids]
# Drop supergroups that have no matching groups after filtering
- data["data"] = [sg for sg in data["data"] if sg["group_ids"]]
+ data["data"] = [sg for sg in data.get("data", []) if sg["group_ids"]]
return Response(data)This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bd2c305. Configure here.
The TypedDict guarantees the "data" key exists. Defensive .get() was misleading and would silently return wrong data on a malformed response instead of failing loudly.
cvxluo
approved these changes
Apr 7, 2026
|
|
||
| return Response(orjson.loads(response.data)) | ||
| data: SupergroupsByGroupIdsResponse = orjson.loads(response.data) | ||
|
|
Contributor
There was a problem hiding this comment.
thoughts on
Suggested change
| if not status_param: | |
| return Response(data) |
| # Instead, collect every group_id from the response, check status in | ||
| # bulk, and strip out non-matching ones. | ||
| if status_param is not None: | ||
| all_response_group_ids: set[int] = set() |
Contributor
There was a problem hiding this comment.
since a group can be a part of at most one supergroup, we shouldn't need to dedupe here
george-sentry
pushed a commit
that referenced
this pull request
Apr 9, 2026
The status filter from #112216 was pre-filtering group IDs sent to Seer, but Seer returns all group_ids per supergroup regardless of what was requested - so the response still contained resolved groups. Moved filtering to the response side instead. Also fixes the response key from `"supergroups"` to `"data"` to match the actual Seer response model (`GetSupergroupsByGroupIdsResponse`). The old code was referencing the wrong key so the filtering was silently a no-op. fixes https://linear.app/getsentry/issue/ID-1440/hide-resolved-issues-from-counts-and-lists --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.


The status filter from #112216 was pre-filtering group IDs sent to Seer, but Seer returns all group_ids per supergroup regardless of what was requested - so the response still contained resolved groups. Moved filtering to the response side instead.
Also fixes the response key from
"supergroups"to"data"to match the actual Seer response model (GetSupergroupsByGroupIdsResponse). The old code was referencing the wrong key so the filtering was silently a no-op.fixes https://linear.app/getsentry/issue/ID-1440/hide-resolved-issues-from-counts-and-lists