fix(seer): Make Seer repo preferences cleanup synchronous to prevent stale dual-writes#112949
Draft
fix(seer): Make Seer repo preferences cleanup synchronous to prevent stale dual-writes#112949
Conversation
…dual-writes Extract cleanup logic from Celery tasks into synchronous helpers in autofix/utils.py and call them directly from impl.py and organization_repository_details.py. This closes the race window where async Seer cleanup allowed stale preferences (with disabled/hidden repos) to be read back from Seer and dual-written into SeerProjectRepository before the cleanup task ran. The tasks are kept as thin wrappers (renamed with _task suffix) for any future async callers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
srest2021
commented
Apr 14, 2026
| @@ -100,12 +100,13 @@ def put(self, request: Request, organization: Organization, repo_id) -> Response | |||
| repository_cascade_delete_on_hide.apply_async(kwargs={"repo_id": repo.id}) | |||
Member
Author
There was a problem hiding this comment.
Note that this thing which deletes associated SeerProjectRepository is still asynchronous.
If read flag is off: we read and write existing prefs from Seer which are now updated synchronously. ✅
If read flag is on: we read and write existing prefs from Sentry which may be stale, just like all the other Repository child relations. However they will be eventually deleted from Sentry via the above task, and from Seer via its own cleanup cron. ✅
So I think we are ok here.
Contributor
Backend Test FailuresFailures on
|
srest2021
commented
Apr 14, 2026
| lambda: cleanup_seer_repository_preferences( | ||
| organization_id=repo.organization_id, | ||
| repo_external_id=repo.external_id, # type: ignore[arg-type] | ||
| repo_provider=repo.provider, # type: ignore[arg-type] |
Member
Author
There was a problem hiding this comment.
mypy keeps complaining even though these can't be none
Contributor
Backend Test FailuresFailures on
|
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.
Extract cleanup logic from Celery tasks into synchronous helpers in autofix/utils.py and call them directly from impl.py and organization_repository_details.py. This closes the race window where async Seer cleanup allowed stale preferences (with disabled/hidden repos) to be read back from Seer and dual-written into SeerProjectRepository after they had already been deleted.