fix(cli,host-service): report per id what workspace delete did

Merged
KI
1mo ago
+529-39

Problem

superset workspaces delete --local/--host reported every id as deleted. The host returns success for an id it has no row for, such as an unknown id, a short prefix, or a workspace on another host. An error on one id also stopped the batch. With --json, a partial failure put the deleted ids only inside the error text, so scripts could not parse them.

Root cause

The host destroy saga answers success: true when it finds no row, and the CLI did not look at the result. The CLI also had no way to return data together with a non-zero exit, so a partial failure could only throw a plain CLIError.

Fix

  • host-service: the destroy result gets an additive found field. Unknown ids still succeed for existing callers.
  • cli: each id is reported as deleted (with teardown warnings), not found, or failed with its reason. Against a host without found, the CLI checks workspace.get after the delete.
  • cli-framework: CLIError takes optional data. Under --json the runner prints it to stdout, then reports the error on stderr and exits 1. Without --json the output does not change.
  • cli: the host and cloud branches always return { deleted, notFound, failed, warnings }. The command still exits non-zero when notFound or failed is not empty, with the same lines and hint.
  • A regression test pins that teardown runs before the worktree is removed and that a teardown failure is reported.

Compat

  • found is an additive output field on workspace.delete and workspaceCleanup.destroy. No input, error code, or procedure type changes. No MIN_HOST_SERVICE_VERSION bump is needed.
  • The --json data of workspaces delete gets new fields. Existing fields keep their names.
  • Unknown ids on a host now exit non-zero. Scripts that deleted unknown ids may notice this.

Verification

  • bun run typecheck in packages/cli and packages/cli-framework: pass.
  • bun test in packages/cli (428 pass) and packages/cli-framework (75 pass).
  • New tests: the runner prints CLIError data under --json and exits 1, and prints only the error under --quiet. A mixed host batch and a mixed cloud batch carry every id in the error data.
  • bun run lint:fix: clean.
  • Not run against a real host or cloud workspace.

Summary by cubic

superset workspaces delete now reports each ID as deleted, not found, or failed, and continues after individual errors. Partial results are available as structured JSON, while missing or failed IDs still produce a non-zero exit.

Behavior

  • Host responses include an additive found field; older hosts are checked with workspace.get, and check errors count as failures.
  • Host and cloud results include { deleted, notFound, failed, warnings }; teardown warnings are preserved.

Compatibility

  • found is output-only and needs no host version bump. Unknown IDs now cause a non-zero exit, and JSON output includes the new fields.

Summary by CodeRabbit

  • New Features

    • Workspace archiving now reports deleted, missing, and failed workspaces, along with any warnings. It continues processing other workspaces after an individual deletion fails, and partial failures include outcome details.
    • In JSON mode, CLI errors can include structured data in the output.
  • Bug Fixes

    • Host workspace deletion now distinguishes missing workspaces from deleted ones and reports teardown warnings when cleanup encounters issues.