Skip to content

mocactl workloads delete: deleted-status workload returns "no workload or it is not yours" instead of a status-specific error #602

Closed

Description

@evaline-ju

Summary

mocactl workloads delete <id> on a workload that is already in status: deleted returns an error that is identical to the error for a workload ID that never existed:

no workload 'wl-c409a2a4' (or it is not yours)

The two conditions should be distinguishable. Today an operator cannot tell whether they typed the wrong ID, deleted it already, or genuinely do not own it — all three fail the same way. For a batch cleanup script or a demo teardown, this is the difference between "retry a different ID" and "move on, this one is already handled."

Reproduction

Reproduced against upstream main at c94ef27b.

export SH_CONTROL_PLANE_URL=http://127.0.0.1:8090
export SH_HARNESS_URL=http://127.0.0.1:8080

# Case A: workload exists, deleted
mocactl workloads create --context /tmp/probe.context --json   # → wl-c409a2a4
mocactl workloads delete wl-c409a2a4                           # → "deleted workload wl-c409a2a4"
mocactl workloads delete wl-c409a2a4                           # → "no workload 'wl-c409a2a4' (or it is not yours)"
mocactl workloads get    wl-c409a2a4 --json                    # → {... "status": "deleted" ...}

# Case B: workload never existed
mocactl workloads delete wl-never00                            # → "no workload 'wl-never00' (or it is not yours)"

Both cases return the identical error string, but workloads get on Case A still returns the record with status: "deleted" — proving the workload is owned by the caller and the harness has state for it.

Suggested fix

Return distinct errors:

  • Case A (status: deleted): workload wl-xxx is already deleted — exit 0 or a dedicated non-fatal exit code, since the operator's intent is satisfied.
  • Case B (not in the user's keyspace): no workload 'wl-xxx' (or it is not yours) — current error is fine here.
  • Owned by another user, exists on server: a separate permission denied error — not conflated with "doesn't exist."

Idempotent delete (Case A exit 0) matches Kubernetes kubectl delete semantics and makes batch cleanup scripts straightforward: "run workloads delete on each known id, treat already-deleted as success."

Activity

  1. added
    bug
    on Oct 23, 2026
  2. added a commit that references this issue on Nov 4, 2026
    f073813
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions