Skip to content

feat(deletions): Add CLI command to list and run scheduled deletions#112018

Merged
leeandher merged 9 commits intomasterfrom
leander/deletion-script
Apr 1, 2026
Merged

feat(deletions): Add CLI command to list and run scheduled deletions#112018
leeandher merged 9 commits intomasterfrom
leander/deletion-script

Conversation

@leeandher
Copy link
Copy Markdown
Member

@leeandher leeandher commented Apr 1, 2026

adds sentry deletions list and sentry deletions run commands 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

image image

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>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 1, 2026
Move _schedule_org_integration_deletion into a DeletionsTestMixin
for cleaner test organization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
leeandher and others added 2 commits April 1, 2026 13:21
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>
@leeandher leeandher requested review from a team April 1, 2026 17:42
@leeandher leeandher marked this pull request as ready for review April 1, 2026 17:42
@leeandher leeandher requested a review from a team as a code owner April 1, 2026 17:42
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>
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>
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 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>
Copy link
Copy Markdown
Member

@alexsohn1126 alexsohn1126 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this 🙏

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>
@leeandher leeandher merged commit e66a9cc into master Apr 1, 2026
65 checks passed
@leeandher leeandher deleted the leander/deletion-script branch April 1, 2026 19:50
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.

3 participants