Skip to content

feat: add project delete command#397

Open
MathurAditya724 wants to merge 8 commits intomainfrom
feat/adi/project-delete
Open

feat: add project delete command#397
MathurAditya724 wants to merge 8 commits intomainfrom
feat/adi/project-delete

Conversation

@MathurAditya724
Copy link
Member

@MathurAditya724 MathurAditya724 commented Mar 11, 2026

Summary

Add sentry project delete subcommand for permanently deleting Sentry projects via the API.

Changes

  • src/commands/project/delete.ts — New command with safety measures:
    • Requires explicit <org>/<project> or <project> target (no auto-detect)
    • Interactive confirmation prompt (strict confirmed !== true check for Symbol(clack:cancel) gotcha)
    • --yes/-y flag to skip confirmation for CI/agent usage
    • --dry-run/-n flag to validate inputs and show what would be deleted without deleting
    • Refuses to run in non-interactive mode without --yes
    • Verifies project exists via getProject() before prompting
    • 403 errors throw ApiError with actionable message (preserves HTTP status for upstream handlers)
  • src/commands/project/index.ts — Registered delete in project route map
  • src/lib/api-client.ts — Added deleteProject() using @sentry/api SDK's deleteAProject
  • src/lib/oauth.ts — Added project:admin to OAuth scopes (required for project deletion; existing users must re-run sentry auth login)
  • test/commands/project/delete.test.ts — 10 unit tests covering happy path, error cases, dry-run, JSON output, and safety checks

Usage

sentry project delete acme-corp/my-app
sentry project delete my-app
sentry project delete acme-corp/my-app --yes
sentry project delete acme-corp/my-app --json --yes
sentry project delete acme-corp/my-app --dry-run

Notes

  • Existing tokens do not include project:admin — users need to re-authenticate via sentry auth login after upgrading
  • Local caches (DSN cache, project cache, defaults) are not cleared after deletion — stale entries may persist until TTL expiry (follow-up)

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)
@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Init

  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Issue List

  • Auto-compact when table exceeds terminal height by BYK in #395
  • Redesign table to match Sentry web UI by BYK in #372

Other

  • Add project delete command by MathurAditya724 in #397
  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Init

  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Other

  • Convert Tier 2-3 commands to return-based output and consola by BYK in #394
  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Codecov Results 📊

104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 90.00%. Project has 913 uncovered lines.
❌ Project coverage is 95.47%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
api-client.ts 75.87% ⚠️ 237 Missing
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
@MathurAditya724 MathurAditya724 marked this pull request as ready for review March 11, 2026 19:35
@MathurAditya724 MathurAditya724 requested review from BYK and betegon and removed request for BYK March 11, 2026 19:35
MathurAditya724 and others added 4 commits March 12, 2026 01:11
- 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.
const SCOPES = [
"project:read",
"project:write",
"project:admin",
Copy link
Member

Choose a reason for hiding this comment

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

what would happen if someone doesn't have this permission? would it face trouble signing in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants