feat(deletions): Add CLI command to list and run scheduled deletions#112018
Merged
feat(deletions): Add CLI command to list and run scheduled deletions#112018
Conversation
Add `sentry deletions list` and `sentry deletions run` commands for managing scheduled deletions locally. This allows developers to run pending deletions synchronously instead of waiting for the periodic Celery task (which runs every 15 minutes). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move _schedule_org_integration_deletion into a DeletionsTestMixin for cleaner test organization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Assign ecosystem team ownership for the new deletions command and its tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace DeletionsTestMixin with two subclasses with a single test class to fix mypy attr-defined errors on mixin attributes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add --verbose flag to show full tracebacks on failure, output errors to stderr, and note that deletion records are preserved for retry. Type _run_one with keyword-only args and ScheduledDeletion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The run subcommand now filters by in_progress=False and date_scheduled<=now() when using --model or --all, matching the behavior of the Celery scheduler. The --id path is unchanged since it targets a specific deletion explicitly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GabeVillalobos
approved these changes
Apr 1, 2026
The CLI was only querying ScheduledDeletion (control silo), missing cell-silo models like Organization, Project, and Team which use CellScheduledDeletion. Now queries both tables in monolith mode, gracefully skipping unavailable tables in single-silo contexts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Both ScheduledDeletion and CellScheduledDeletion use independent auto-increment IDs, so overlapping IDs are common. Add --cid flag to target cell-silo deletions explicitly, and show the table model name in list output so entries are unambiguous. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add BaseScheduledDeletion type annotation for model_cls and use explicit DoesNotExist references for both model classes to satisfy mypy's type narrowing. 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.

adds
sentry deletions listandsentry deletions runcommands so you can manage and execute scheduled deletions synchronously in local dev instead of waiting for the task to run.includes tests for both subcommands covering listing, filtering, and running deletions by id/model/all.
wanted this for uninstalling integrations