feat(seer): Backfill SeerAgentRun.group_id from autofix category_value#117561
Merged
trevor-e merged 1 commit intoJun 12, 2026
Merged
Conversation
Contributor
|
This PR has a migration; here is the generated SQL for for --
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL |
3d7c390 to
3518493
Compare
SeerAgentRun.group_id was only recently wired up, so historical autofix rows have it unset. For autofix runs, extras["category_value"] holds the stringified group id, so use it to recover group_id in batches. Only link when the resolved group's org matches the run's org. In a healthy system category_value is always the run's own group, so this only ever rejects corrupt or foreign data — but as a tenant-isolation guard it guarantees the backfill can never link a run to another org's group, and it backstops the assumption that an autofix row's category_value really is a group id. A group that no longer exists is skipped rather than written as a stale id. category_value is parsed defensively (str.isdigit() is not a safe int() guard for unicode digits) and bounded to the bigint range so malformed data is skipped, never crashing the migration. This is a prerequisite for switching the autofix issue-details path to a local group_id lookup. Refs AIML-2954 Co-Authored-By: Claude <noreply@anthropic.com>
3518493 to
f4458a7
Compare
NicoHinderling
approved these changes
Jun 12, 2026
3 tasks
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.
Summary
Backfills
SeerAgentRun.group_idfor historical autofix rows.group_idwas only recently wired up, so existing rows lack it — a prerequisite for the localgroup_idlookup in the autofix issue-details path.For autofix runs,
extras["category_value"]is the stringified group id. The migration setsgroup_idfrom it for rows wheresource="autofix"andgroup_id IS NULL. (Thesourcefilter is load-bearing: other sources likedashboard_generateput unrelated ids incategory_value.)Defensive guarantees
Given this is a multi-tenant table, the backfill validates before linking rather than trusting
category_value:group.project.organization_id) matches the run's org. A corrupt or foreigncategory_valuecan never link a run to another org's group — it's skipped. This also backstops the assumption that anautofixrow'scategory_valuereally is a group id.category_valueis parsed withint()+ bigint-range bound rather thanstr.isdigit()(which returnsTruefor unicode digits like"²"thatint()then rejects), so malformed data is skipped instead of crashing the migration.Counts for each skip reason (
bad_value/missing_group/org_mismatch) and the linked total are logged.is_post_deployment = True— run manually after deploy.Test plan
tests/sentry/seer/migrations/test_0018_...covers: same-org autofix row (linked), cross-org group (skipped), missing group (skipped), already-set group_id (untouched), non-autofix source (skipped), and missing / non-numeric / unicode-digit / oversizedcategory_value(skipped). Passes withpytest --migrations.Refs AIML-2954