Skip to content

fix: surface insufficient access error on org delete sandbox#1647

Open
ZLeventer wants to merge 1 commit intosalesforcecli:mainfrom
ZLeventer:fix/sandbox-delete-insufficient-access-error
Open

fix: surface insufficient access error on org delete sandbox#1647
ZLeventer wants to merge 1 commit intosalesforcecli:mainfrom
ZLeventer:fix/sandbox-delete-insufficient-access-error

Conversation

@ZLeventer
Copy link
Copy Markdown

When a user without the "Manage Sandboxes" system permission runs sf org delete sandbox, the Tooling API returns INSUFFICIENT_ACCESS_OR_READONLY. Currently that error propagates as an unhandled exception with a raw API message.

This PR catches that specific error code in the existing catch block and surfaces it as a clean SfError with an actionable message pointing the user to their Salesforce admin.

Why not a pre-flight permission check?

org.delete() operates against the production org's Tooling API — checking a PermissionSet on the sandbox org (as proposed in #1565) would query the wrong org. Catching the real API error after the fact is simpler, always targets the right org, requires no custom PermissionSet setup by customers, and handles the case where permissions change between the check and the actual delete.

Closes #1565 (alternative approach)

@ZLeventer ZLeventer requested a review from a team as a code owner April 25, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant