Skip to content

fix(main): exit non-zero when Cobra returns an error - #269

Open
stantheman0128 wants to merge 1 commit into
zeabur:mainfrom
stantheman0128:fix/main-exit-code
Open

fix(main): exit non-zero when Cobra returns an error#269
stantheman0128 wants to merge 1 commit into
zeabur:mainfrom
stantheman0128:fix/main-exit-code

Conversation

@stantheman0128

@stantheman0128 stantheman0128 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

When a Cobra subcommand returned an error, main logged it but the process still exited 0. That broke shell scripts and CI that rely on $? after zeabur ... failures (for example invalid flags or missing required args).

Refactor to run() int and os.Exit(run()) so any Execute() error returns exit code 1. Subcommands that call os.Exit with a remote command status (service exec, server exec) are unchanged.

Related to #268 (npm wrapper exit propagation); this fixes the Go entrypoint path.

AI disclosure

AI-assisted patch; human-reviewed by Stan Shih (stantheman0128) before publish.

Verification / Evidence

go test ./cmd/... -v -count=1
# TestRun_UnknownSubcommandReturnsNonZero PASS (run() non-zero)
# TestRun_VersionReturnsZero PASS (run() == 0)

go test ./... -count=1   # green

Before: go run ./cmd/main.go this-subcommand-does-not-exist exited 0 on Windows 11.
After: same invocation exits 1.

What was not tested

  • Live npx zeabur end-to-end against the published npm tarball (local go run only).

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Return 1 from run() so shell scripts see failures from invalid commands and flag errors. Subcommands that os.Exit with remote status are unchanged.

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant