fix(cli): exit 3 when the API rejects the key with HTTP 401 - #1520
Merged
Conversation
|
Warning Review limit reachedNext included review available in 6 minutes. View limit detailsLimit details: You’ve used all 3 included reviews currently available. Your 43 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (11)
Comment |
Chase J (chajac)
marked this pull request as ready for review
August 24, 2026 11:39
Simon Ingeson (smonn)
approved these changes
Aug 24, 2026
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.
Note
PR body AI drafted & edited as needed
Overview of Changes
The documented exit-code contract maps code 3 to "
QAWOLF_API_KEYis missing or invalid", but only the missing case honored it. A present-but-invalid key sailed past the localrequireApiKeycheck, got a 401 from the API, and surfaced as the default exit 1 — so a CI wrapper branching on exit status misclassified a bad key as a test failure. Root cause:describeRequestErrorcollapsed the structured wire error (which knowsstatus: 401) into a display string, so the layer that picks exit codes had no auth signal left to act on.src/shell/platform/requestWithRetry.ts:PlatformFailuregains an optionalexitCode, set when a failure kind maps to a documented CLI exit code;failureFieldspasses it through (omitted entirely when unset, likeerrorBody).src/shell/platform/describeErrors.ts:describeRequestErroranddescribeIdentityErrorsetexitCode: exitCodes.authon HTTP 401 only, with comments recording why 403 is excluded.src/commands/auth/whoami.ts: the missing-key path returns exit 3, and the invalid-key path passes the identity failure's exit code through instead of flattening to the default.src/domains/publicApi/handle.ts: no change needed — the code flows throughfailureFieldsintowithAuthContext's existingresult.exitCode ?? 1wiring, covering every generated public-API command at once.whoami.failures.test.ts;handle.test.ts's spec/ctx helpers extracted tohandle.testUtils.ts.Testing
bun run test bun run typecheck bun run lint bun run format:check bun run knipdescribeErrors.test.ts,requestWithRetry.test.ts,handle.test.ts,createPlatformClient.callPublicApi.test.ts, andwhoami.failures.test.ts: 401 resolves the auth exit code at each layer; 403/404/500, network, and timeout failures leave it unset;failureFieldspreserves it; both whoami failure paths return it.QAWOLF_API_KEY=definitely_not_a_real_key>tag listandauth whoamiboth exit 3 (previously 1); a valid key still exits 0; a missing key still exits 3.Checklist