cli icon indicating copy to clipboard operation
cli copied to clipboard

sfdx force:org:delete can't delete a sandbox

Open MarcDBehr opened this issue 1 year ago • 3 comments

Summary

The help text for the sfdx force:org:delete command states it can be used to "mark a scratch or sandbox org for deletion", but if you run the command against a sandbox, it fails stating "ERROR running force:org:delete: Unable to associate this scratch org with a DevHub."

Steps To Reproduce:

  1. Create a developer sandbox via the UI
  2. Authenticate with the sandbox using sfdx force:auth:web:login
  3. Wait > 24 hours
  4. run the command sfdx force:org:delete to try to delete the sandbox

Expected result

The sandbox would be deleted (or remove the wording from the help text that says sandboxes can be deleted)

Actual result

Error message "ERROR running force:org:delete: Unable to associate this scratch org with a DevHub." (even if you specify the devhub on the command line

System Information

  • Which shell/terminal are you using? (e.g. bash, zsh, powershell 5, powershell 7, cmd.exe, etc.)

{ "cliVersion": "sfdx-cli/7.168.0", "architecture": "darwin-x64", "nodeVersion": "node-v16.13.2", "pluginVersions": [ "@dx-cli-toolbox/sfdx-toolbox-package-utils 0.8.3 (user)", "@mshanemc/plugin-streaming 1.1.7 (user)", "@mshanemc/sfdx-sosl 1.1.0 (user)", "@oclif/plugin-autocomplete 1.3.0 (user)", "@oclif/plugin-commands 2.2.0 (core)", "@oclif/plugin-help 5.1.12 (core)", "@oclif/plugin-not-found 2.3.1 (core)", "@oclif/plugin-plugins 2.1.0 (core)", "@oclif/plugin-update 3.0.0 (core)", "@oclif/plugin-version 1.1.2 (core)", "@oclif/plugin-warn-if-update-available 2.0.4 (core)", "@oclif/plugin-which 2.1.0 (core)", "alias 2.1.0 (core)", "apex 1.2.0 (core)", "auth 2.2.3 (core)", "community 2.0.1 (core)", "config 1.4.19 (core)", "custom-metadata 2.0.0 (core)", "data 2.1.2 (core)", "generator 2.0.2 (core)", "info 2.0.1 (core)", "limits 2.0.1 (core)", "org 2.2.0 (core)", "packaging 1.6.0 (core)", "schema 2.1.1 (core)", "signups 1.2.0 (core)", "source 2.0.13 (core)", "telemetry 2.0.0 (core)", "templates 55.1.0 (core)", "trust 2.0.3 (core)", "user 2.1.0 (core)", "@salesforce/sfdx-diff 0.0.6 (user)", "@salesforce/sfdx-plugin-lwc-test 1.0.1 (core)", "bbdoc 4.0.5 (user)", "salesforce-alm 54.8.1 (core)", "sfdmu 4.15.5 (user)", "sfdx-flowdoc-plugin 0.5.1 (user)", "sfdx-waw-plugin 1.5.0 (user)", "sfdxdatadicgen 0.1.2 (user)", "sfpowerkit 5.0.0 (user)", "shane-sfdx-plugins 4.43.0 (user)" ], "osVersion": "Darwin 21.6.0", "shell": "bash", "rootPath": "/usr/local/lib/node_modules/sfdx-cli" }

Additional information

That is all!

MarcDBehr avatar Sep 22 '22 18:09 MarcDBehr

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

github-actions[bot] avatar Sep 22 '22 18:09 github-actions[bot]

This issue has been linked to a new work item: W-11831532

git2gus[bot] avatar Sep 29 '22 19:09 git2gus[bot]

Unable to associate this scratch org with a DevHub

that error means sfdx didn't detect that org as a sandbox (so defaulted to scratch).

I've narrowed the bug down to this line in the force:org:delete command: https://github.com/salesforcecli/plugin-org/blob/main/src/commands/force/org/delete.ts#L34

that isSandbox() method relies on a file <ORG-ID>.sandbox.json to be present in ~/.sfdx to detect a sandbox.

When authenticating to a sandbox with force:auth:web:login that file isn't written, the workaround for this is to auth to a sbx using force:org:status.

Thanks for reporting!

cristiand391 avatar Sep 29 '22 19:09 cristiand391