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
bug: Commands exit with code 0 when they fail, and show incorrect error text #2
Blocker: yes. Fix this before the server-monitoring work starts.
Defect
Most commands use Run. They show the error, but the process exits with code 0.
Test: fly exec -- php sh -c 'exit 7' with Docker Compose v5.1.1. Result: the CLI shows Error executing command: exit status 7 and exits with code 0.
The exit codes are not consistent. base start and logs exit with code 1 when they fail. start, stop, restart, wp, exec, base stop, base restart, sites * and update exit with code 0.
Eight calls give err to color.Red without a format verb. color.Red uses a printf format. Thus, the output shows %!(EXTRA *exec.ExitError=exit status 1).
Locations: cmd/base.go:41,53,57,61 and cmd/site.go:43,60,80,84.
go vet does not find this defect.
base stop and base restart show "…successfully" after they show an error.
The CLI sends errors to stdout, not to stderr. Thus, errors mix with the output in a pipe, for example fly wp … | jq.
If a user who is not root runs fly update, the CLI shows an error and exits with code 0.
Cost
Scripts and automation cannot identify a failure.
The control plane and the event emitter will not get a correct result from each operation.
New capabilities will copy the current error pattern. The Cursor rules on main tell AI tools to use this pattern.
Users see incorrect text and incorrect success messages. This decreases their trust in the tool.
Benefit of the fix
Each command gives a correct exit code. Scripts, the control plane and the event emitter can use this code.
The CLI gives the exit code of the container command to the caller without change.
Error messages are clear and go to stderr.
New capabilities start from a correct error pattern.
Fix
Use RunE on each command.
Set SilenceUsage: true on the root command. Show the error one time in Execute().
Get the exit code from *exec.ExitError. Exit with the same code.
Remove os.Exit from the command bodies.
Send errors and warnings to stderr.
Completion checks
fly exec -- php sh -c 'exit 7'; echo $? shows 7.
Each command exits with a code that is not 0 when its Docker call fails.
No command shows a success message after a failure.
Errors go to stderr.
Regression tests use a fake docker script on PATH.
changed the title [-]Commands exit with code 0 when they fail, and show incorrect error text[/-][+]bug: Commands exit with code 0 when they fail, and show incorrect error text[/+]on Oct 1, 2026
Activity
fix(cli): return correct exit codes and report errors on stderr (#18)
[-]Commands exit with code 0 when they fail, and show incorrect error text[/-][+]bug: Commands exit with code 0 when they fail, and show incorrect error text[/+]