Skip to content

fix: KEEP-1191 exit non-zero when a write fails before the first poll - #105

Merged
suisuss merged 1 commit into
mainfrom
fix/KEEP-1191-wait-exit-code
Aug 17, 2026
Merged

fix: KEEP-1191 exit non-zero when a write fails before the first poll#105
suisuss merged 1 commit into
mainfrom
fix/KEEP-1191-wait-exit-code

Conversation

@suisuss

@suisuss suisuss commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

A write response can already carry a terminal status. When that status was failed, the immediate branch in cmd/execute/transfer.go and cmd/execute/contract_call.go printed the result table and returned nil, so kh ex transfer --wait and kh ex cc --wait exited zero on a write that failed. The identical failure discovered one poll later exited non-zero, because pollExecStatus classified it separately and did so correctly.

A script gating on kh ex transfer --wait && ./next-step.sh therefore proceeded on a failed transfer, but only when the failure was fast enough to be in the write response.

Root cause is duplication: two places decided what a terminal status meant, and they disagreed. Both now call terminalExecError, so the decision cannot drift again. The write response carries no error field, so that path reports the execution id; the status path keeps surfacing the server's message.

Both new tests were mutation-checked - reverting the guard makes each fail with expected an error ..., got nil, which is the reported symptom.

go build, go vet and go test -race ./... all pass. Formatting note: cmd/execute/{transfer,contract_call,status}_test.go and status.go are unformatted on main (an IOStreams: alignment); I left that alone rather than mixing an unrelated reformat into this change.

Merge order matters. Open contributor PRs #95 and #99 both rework this same terminal-status handling in transfer.go, and they already conflict with each other. Landing this first means each rebases once onto the shared helper rather than reconciling three versions.

Tracked as KEEP-1191. Found while finishing #95 and #99; pre-existing on main, not introduced by either.

A write response can already carry a terminal status. When that status was
"failed", the immediate branch printed the result table and returned nil, so
`kh ex transfer --wait` and `kh ex cc --wait` exited zero on a failed write.
The identical failure discovered one poll later exited non-zero, because
pollExecStatus classified it separately and did so correctly.

Two paths decided what a terminal status meant and disagreed. Both now call
terminalExecError, so the decision cannot drift again. The write response
carries no error detail, so that path reports the execution id; the status
path keeps surfacing the server message.
@suisuss suisuss added the no-issue-required PR exempt from the issue-first gate label Aug 17, 2026
@suisuss
suisuss merged commit fba4127 into main Aug 17, 2026
5 of 6 checks passed
@suisuss
suisuss deleted the fix/KEEP-1191-wait-exit-code branch August 17, 2026 23:42
@eskp eskp mentioned this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-issue-required PR exempt from the issue-first gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant