fix(create): exit 5 on InitTask insufficient_credits (0.5.1)#4
Merged
Conversation
InitTask's insufficient_credits handler returned a plain fmt.Errorf which cobra mapped to its default exit 1, while the same condition surfacing later in the stream path explicitly os.Exit(5). The documented contract (AGENTS.md, README) is 5 = business failure; agents branching on exit codes had to know about two paths. Caught during real-backend smoke for 0.5.0 (depleted credits during testing made the inconsistency observable). Match the stream-side pattern verbatim: print the i18n message to stderr, os.Exit(5). Add an integration test that mocks /v1/tasks/init returning envelope code 100001 and asserts the binary exits 5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A 0.5.1 patch that fixes an exit-code inconsistency surfaced during 0.5.0 real-backend validation.
Before:
vk createexited 1 whenPOST /v1/tasks/initreturnedinsufficient_credits(envelope code 100001), via cobra's generic error handler.After: exits 5 (business failure), matching:
cmd/create.go:259— alreadyos.Exit(5))AGENTS.md/README(5 = business failure)Agents branching on exit codes no longer need to know about two different paths for the same condition.
Diff
cmd/create.go: replacereturn fmt.Errorf(...)withfmt.Fprintln(os.Stderr, ...); os.Exit(5)— verbatim mirror of the stream-side handler 4 lines below.tests/integration/create_credits_test.go(new): mocks/v1/tasks/initreturning envelope code 100001, asserts binary exits 5 and stderr carries the message.CHANGELOG.md: 0.5.1 entry under Fixed.package.json+ 3SKILL.md: 0.5.0 → 0.5.1.Test plan
go test ./...passes including new integration testgo build ./...cleanOut of scope
auth statusshowing valid but token refresh actually failing — was also observed during 0.5.0 validation but the root cause is non-obvious; needs middleware-level diagnostics before fix. Tracked separately.