Skip to content

fix(supergroups): Filter resolved groups from Seer response#112403

Merged
scttcper merged 5 commits intomasterfrom
scttcper/supergroup-status-filter
Apr 7, 2026
Merged

fix(supergroups): Filter resolved groups from Seer response#112403
scttcper merged 5 commits intomasterfrom
scttcper/supergroup-status-filter

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented Apr 7, 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

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 7, 2026
Comment thread src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py Outdated
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>
@scttcper scttcper marked this pull request as ready for review April 7, 2026 20:41
@scttcper scttcper requested review from a team as code owners April 7, 2026 20:41
Comment thread src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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 missing data sets data["data"] to [] instead of raising KeyError.

Create PR

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.

Comment thread src/sentry/seer/supergroups/endpoints/organization_supergroups_by_group.py Outdated
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.

return Response(orjson.loads(response.data))
data: SupergroupsByGroupIdsResponse = orjson.loads(response.data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since a group can be a part of at most one supergroup, we shouldn't need to dedupe here

@scttcper scttcper merged commit 3d4d71b into master Apr 7, 2026
57 checks passed
@scttcper scttcper deleted the scttcper/supergroup-status-filter branch April 7, 2026 22:20
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>
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