Skip to content

Require an exit code before exec reports success - #70

Open
MiguelsPizza wants to merge 1 commit into
kernel:mainfrom
MiguelsPizza:exec-exit-status
Open

MiguelsPizza wants to merge 1 commit into
kernel:mainfrom
MiguelsPizza:exec-exit-status

Conversation

@MiguelsPizza

@MiguelsPizza MiguelsPizza commented Oct 3, 2026 •

Copy link
Copy Markdown

Non-interactive hypeman exec returns 0 when the WebSocket closes without an {"exitCode":N} message (dropped connection, normal close, malformed or null code), and a received nonzero code can also lose the final select to the reader's done channel. This makes the exit code message required: anything else returns an error instead of success. The interactive TTY path is unchanged.

Tests: go test -count=1 ./pkg/cmd/ -run TestRunExecNonInteractive. On main all four TestRunExecNonInteractiveRequiresExitCode cases fail with "An error is expected but got nil"; they pass with the fix.


Note

Medium Risk
Changes CLI exit semantics for non-interactive exec (scripts/CI may now fail on connection issues), but tightens correctness and does not alter the interactive path.

Overview
Non-interactive hypeman exec no longer reports success unless the server sends a valid {"exitCode":N} text message.

runExecNonInteractive drops the doneCh fallback that returned exit 0 when the WebSocket closed cleanly, and treats any read error (including normal close or a dropped connection) as failure with "websocket closed before receiving an exit code". Exit codes are parsed with a nullable *int so malformed JSON, null, or missing values do not count as success. Interactive TTY exec behavior is unchanged.

Adds WebSocket harness tests for propagating a nonzero exit code and for the cases that must now error instead of exiting 0.

Reviewed by Cursor Bugbot for commit 26e80bb. Bugbot is set up for automated code reviews on this repo. Configure here.

Non-interactive exec returned 0 when the WebSocket closed without an
exit code message, and the exit code could lose a select race to the
reader's done channel. Treat a missing or malformed exit code as an error.
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