Repository navigation
Description
Reported from the 2026-10-07 demo for spawn terminate. Confirmed, and it is a
class, not one command.
Reproduced
cmd/terminate.go:111:
if !confirmTerminate(fmt.Sprintf("Permanently terminate %s?", label)) {
fmt.Fprintln(os.Stderr, "Aborted.")
return nil // <- exit 0
}With non-interactive stdin the read fails, confirmYes returns false, Aborted.
is printed, the process exits 0, and the instance keeps running and billing.
The reporter first read this as "terminate silently did nothing", because an
output filter hid the prompt — which is the real hazard: the only thing
distinguishing success from a no-op was a line on stderr.
Every abort site in the CLI does the same. All eleven return nil:
| file:line | command |
|---|---|
cmd/terminate.go:112 |
terminate (single) |
cmd/terminate.go:177 |
terminate (job array) |
cmd/cancel.go:132 |
cancel |
cmd/cleanup.go:152 |
cleanup |
cmd/dns.go:217 |
dns |
cmd/alerts.go:342 |
alerts |
cmd/team.go:282, :310 |
team |
cmd/autoscale_lifecycle.go:131 |
autoscale |
cmd/pipeline.go:682 |
pipeline |
cmd/reaper.go:193 |
reaper arm |
cmd/bot.go:607 |
bot |
The cost-safety ones matter most — terminate, cleanup, cancel, and the
job-array path, which can leave an entire cohort running.
Why exit 0 is wrong here
spawn terminate exiting 0 means "the instance is not running any more". On an
abort that is false. An agent or a CI step that checks the exit code — the normal
way to drive this — concludes the spore is gone and stops watching. Cost control
is existential for this project, and this is the one path where a wrong exit code
costs money indefinitely.
Note the asymmetry already established in #648 is about something different and
should be preserved: a name that resolves to nothing is success (the instance is
already gone, which is what the caller wanted). An abort is the opposite — the
instance is definitely still there.
Suggested fix
Return a distinct non-zero exit for "user declined". Concretely:
- A shared
errAbortedsentinel returned from all eleven sites, mapped to a
dedicated exit code inmain— not 1, so "you said no" stays
distinguishable from "it failed". Something in the 70s, or reuse the 3 that
--check-completealready uses for its own meaning elsewhere; the number
matters less than it being stable and documented. - Distinguish a declined prompt from an unreadable one.
confirmYes
currently collapses "user typed n" and "stdin is not a terminal" into the same
false. Non-interactive with no--yesis a usage error — the caller forgot
a flag — and deserves a clearer message thanAborted.:
terminate: refusing to prompt on non-interactive stdin; pass --yes. - Document the codes in each command's help, since the whole point is that a
script can branch on them.
spawn terminate <name> --yes works correctly today and finds the instance across
regions, so there is no gap in capability — only in what the exit code says.
Environment: spawn v0.123.0.
Activity
fix(cmd): exit non-zero when a confirmation prompt is declined; fix c…
fix(sweep): a detached sweep launched zero instances and reported suc…
fix(sweep): a detached sweep launched zero instances and reported suc…