You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
spawn launch: exit code 0 on launch failure — makes scripting unreliable #16
spawn launch returns exit code 0 even when the launch fails. This makes it impossible to detect failure in scripts via $? or subprocess.returncode.
Steps to reproduce
spawn launch test --instance-type t4g.small --ami auto -y
echo"exit: $?"# prints "exit: 0" despite the error
Output includes failed to launch instance: ... on stderr/stdout but the process exits 0.
Expected
Non-zero exit code on any launch failure so that scripts can reliably detect and handle errors:
if! spawn launch ...;thenecho"Launch failed"exit 1
fi
Impact
Callers using subprocess.run(..., check=False) and checking returncode != 0 will silently proceed as if the launch succeeded, then fail later when trying to parse the instance ID from empty/error output.
Traced the path: every launch path returns its error to RunE → rootCmd.Execute() returns it (confirmed with an instrumented build) → Execute() runs os.Exit(1). extend and other RunE commands behave the same (exit 1 on error).
One likely explanation for the original observation: a shell pipe can mask the exit code. $? reflects the last command in a pipeline, so:
spawn launch ... | tail # $? is tail's (0), NOT spawn's
spawn launch ...;echo$?# this correctly shows spawn's exit code
I hit exactly this myself while investigating. If your wrapper captured output through a pipe (or tee), $?/returncode could read the wrong process. With subprocess.run([...], capture_output=True) (no shell pipe), returncode should be accurate.
The other factor: your repro used --ami auto, which failed due to #15 (now fixed in #17). With that fix, --ami auto no longer errors at all — so that specific command will now succeed rather than testing the failure path.
What I need to confirm a real bug
If you still see exit 0 on a genuine failure, please paste:
The exact command (no pipe), and echo $? on the very next line.
Whether it's via shell or subprocess (and the exact subprocess call).
Holding this open pending that — happy to fix immediately if there's a path I missed, but I don't want to ship a speculative change to error handling that already appears correct.
spawn launch now returns a non-zero exit code on launch failure. runLaunch is a cobra RunE that returns the error, and cmd.Execute() does os.Exit(1) on a non-nil error (cmd/root.go:49-52, with SilenceErrors: true so the error prints once). Verified live against main (built from HEAD) across several failure modes:
(The original report predates the cobra RunE/Execute exit wiring.) Closing as resolved; reopen if a specific path still exits 0 — happy to add a regression test if you'd like one pinned.
Activity
scttfrdmn commentedon May 31, 2026
Investigated — could not reproduce exit 0; spawn appears to exit 1 correctly
I tried to reproduce this and, measured directly,
spawn launch(and other commands) do exit non-zero on failure:Traced the path: every launch path returns its error to
RunE→rootCmd.Execute()returns it (confirmed with an instrumented build) →Execute()runsos.Exit(1).extendand otherRunEcommands behave the same (exit 1 on error).One likely explanation for the original observation: a shell pipe can mask the exit code.
$?reflects the last command in a pipeline, so:I hit exactly this myself while investigating. If your wrapper captured output through a pipe (or
tee),$?/returncodecould read the wrong process. Withsubprocess.run([...], capture_output=True)(no shell pipe),returncodeshould be accurate.The other factor: your repro used
--ami auto, which failed due to #15 (now fixed in #17). With that fix,--ami autono longer errors at all — so that specific command will now succeed rather than testing the failure path.What I need to confirm a real bug
If you still see exit 0 on a genuine failure, please paste:
echo $?on the very next line.subprocess(and the exactsubprocesscall).Holding this open pending that — happy to fix immediately if there's a path I missed, but I don't want to ship a speculative change to error handling that already appears correct.
scttfrdmn commentedon Jun 25, 2026
Already fixed on
main— verifiedspawn launchnow returns a non-zero exit code on launch failure.runLaunchis a cobraRunEthat returns the error, andcmd.Execute()doesos.Exit(1)on a non-nil error (cmd/root.go:49-52, withSilenceErrors: trueso the error prints once). Verified live againstmain(built from HEAD) across several failure modes:RunInstancesfailure (bad AMI id)InvalidParameterValue)--nameargExample:
(The original report predates the cobra
RunE/Executeexit wiring.) Closing as resolved; reopen if a specific path still exits 0 — happy to add a regression test if you'd like one pinned.