Open
Conversation
Add `sentry project delete` subcommand for permanently deleting Sentry projects via the API. Safety measures: - Requires explicit target (no auto-detect to prevent accidental deletion) - Confirmation prompt with --yes/-y flag to skip - Refuses to run in non-interactive mode without --yes - Verifies project exists before prompting Changes: - src/commands/project/delete.ts: New command implementation - src/commands/project/index.ts: Register delete in route map - src/lib/api-client.ts: Add deleteProject() using @sentry/api SDK - test/commands/project/delete.test.ts: Unit tests (8 tests)
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Init
Other
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 90.00%. Project has 913 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.50% 95.47% -0.03%
==========================================
Files 142 143 +1
Lines 20037 20157 +120
Branches 0 0 —
==========================================
+ Hits 19136 19244 +108
- Misses 901 913 +12
- Partials 0 0 —Generated by Codecov Action |
- Add 'project:admin' to OAuth SCOPES so new tokens include the permission required for project deletion - Catch 403 in project delete command and show actionable message pointing users to re-authenticate or check their org role - Existing tokens require re-login: sentry auth login
- 403 error now throws ApiError (preserving status/detail/endpoint) instead of CliError, so upstream handlers can still match on status - Add --dry-run / -n flag consistent with project create and other mutating commands — validates inputs and shows what would be deleted - Extract resolveDeleteTarget() to reduce func() complexity - Add 2 new dry-run tests (human + JSON output)
…teTarget Replace the custom resolveDeleteTarget() with the shared resolveOrgProjectTarget() from resolve-target.ts. Only the auto-detect guard remains delete-specific — all other resolution modes (explicit, project-search, org-all) are handled by the shared infrastructure. This also gains resolveEffectiveOrg() region routing for the explicit case, which the custom function was missing.
betegon
reviewed
Mar 12, 2026
| const SCOPES = [ | ||
| "project:read", | ||
| "project:write", | ||
| "project:admin", |
Member
There was a problem hiding this comment.
what would happen if someone doesn't have this permission? would it face trouble signing in?
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
Add
sentry project deletesubcommand for permanently deleting Sentry projects via the API.Changes
src/commands/project/delete.ts— New command with safety measures:<org>/<project>or<project>target (no auto-detect)confirmed !== truecheck for Symbol(clack:cancel) gotcha)--yes/-yflag to skip confirmation for CI/agent usage--dry-run/-nflag to validate inputs and show what would be deleted without deleting--yesgetProject()before promptingApiErrorwith actionable message (preserves HTTP status for upstream handlers)src/commands/project/index.ts— Registereddeletein project route mapsrc/lib/api-client.ts— AddeddeleteProject()using@sentry/apiSDK'sdeleteAProjectsrc/lib/oauth.ts— Addedproject:adminto OAuth scopes (required for project deletion; existing users must re-runsentry auth login)test/commands/project/delete.test.ts— 10 unit tests covering happy path, error cases, dry-run, JSON output, and safety checksUsage
Notes
project:admin— users need to re-authenticate viasentry auth loginafter upgrading