fix(cli): fail workspace delete when a cloud workspace is not found

Merged
SA
2mo ago
+12-8

Problem

Without --local or --host, superset workspaces delete targets the cloud when the account has cloud workspaces (#7564). If the cloud doesn't know the id, for example a local worktree workspace or a typo, the command printed Deleted 0 cloud workspaces / Not found: <id> and exited 0. An agent cleaning up its own local workspace this way reported it deleted while the workspace was still there.

Fix

The cloud branch of workspaces delete now throws a CLIError when any id isn't found. That matches workspaces get (which already throws No cloud workspace … in this organization) and the host branch (which fails on an unknown id). The error names any ids that were deleted before the miss and suggests --local/--host. --json output no longer has a missing field; nothing in the repo reads it.

Verification

  • bunx biome check packages/cli/src/commands/workspaces/delete/command.ts: Checked 1 file … No fixes applied.
  • cd packages/cli && bun run typecheck: clean
  • bun test src/commands/workspaces: 31 pass, 0 fail
  • Ran from source against production with a local workspace id and no flag:
    Error: No cloud workspace in this organization: <local-workspace-id>
    Hint: Pass --local or --host <id> if it lives on a machine
    exit=1
    
    Before this change, the same call exited 0 with {"deleted": [], "missing": ["<id>"]}.
  • Not exercised: a successful cloud delete (that code path is unchanged).

Summary by cubic

Fixes superset workspaces delete so it exits non-zero when any cloud workspace id is not found, instead of printing "Deleted 0 cloud workspaces" and exiting 0. The error message lists any ids that were deleted before the miss and suggests --local/--host. --json output no longer includes a missing field.

Summary by CodeRabbit

  • Bug Fixes
    • Workspace deletion now reports an error when any requested IDs are missing, listing the missing IDs and any IDs deleted before the error.
    • Successful deletions now report the deleted ID or the number of workspaces deleted. The success response no longer includes a separate list of missing IDs.