fix(seer): Validate unvalidated coding agent org option values#111862
fix(seer): Validate unvalidated coding agent org option values#111862
Conversation
|
This PR has a migration; here is the generated SQL for for --
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL |
|
This PR has a migration; here is the generated SQL for for --
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL |
Backend Test FailuresFailures on
|
| row.value = canonical | ||
| row.save(update_fields=["value"]) |
There was a problem hiding this comment.
Bug: The migration updates OrganizationOption values but fails to invalidate the cache because it uses a historical model, which bypasses the post_save signal that triggers cache reloading.
Severity: LOW
Suggested Fix
After saving the updated row inside the loop, add an explicit call to OrganizationOption.objects.reload_cache(row.organization_id, "migrate_coding_agent_alias") to manually invalidate the cache, since the post_save signal will not fire for the historical model.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/sentry/migrations/1059_normalize_coding_agent_option_aliases.py#L37-L38
Potential issue: The database migration updates `OrganizationOption` rows directly using
`row.save(update_fields=["value"])` on a historical model instance. In Django
migrations, historical models do not trigger signals like `post_save`. The
`OrganizationOptionManager` relies on this signal to call `reload_cache()` for cache
invalidation. Because the signal is bypassed, the Redis and in-memory caches are not
updated, causing them to serve stale option values. The stale data will persist until
the cache's time-to-live (TTL) expires or the process is restarted.
Did we get this right? 👍 / 👎 to inform future reviews.
Backend Test FailuresFailures on
|
There are currently 2 rows in prod for the org option
sentry:seer_default_coding_agentthat have unvalidated values (ie, "cursor" instead of "cursor_background_agent"). We want coding agent values to match the allowed values for automation handoff target. This is a low risk migration on org options that are currently only used in UI that is feature-flagged for internal use.Followup PR that adds validation: #111697