Repository navigation
Conversation
…"API key rejected" runConfigure wrapped every non-ApiError from the GET /me key check in an exit-3 "API key rejected" CLIError. RequestTimeoutError extends CLIError, not ApiError, so a stalled check told the user their key was rejected and dropped the REQUEST_TIMEOUT code and request id. Rethrow it unchanged (exit 7) and say on stderr that the check timed out; the profile is still not written. Closes TestSprite#614
|
🏆 Season 4 CLI Improvement Bonus: entry recorded. Thanks, @Andy00L! To be counted, this PR needs the following by Oct 29, 11:59 PM PT:
Rewards go to merged PRs judged a genuine improvement, and up to three bonus-eligible PRs count per person. Untick the box to withdraw the entry. This comment refreshes when you edit the PR. Full rules. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughKey verification now preserves client-side request timeout errors instead of treating them as rejected API keys. Tests cover timeout and unauthorized responses, including their error details, exit codes, request IDs, and credential-saving behavior. ChangesSetup key verification
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Possibly related issues
Merge Risk: ⚪ Minimal · up to
|
What does this PR do?
When the
GET /mekey check insetuptimed out on the client side,setuptold the user their API key was rejected and exited 3, the auth family. The natural reaction is to rotate a key that works. The same stall on any other command givesREQUEST_TIMEOUTand exit 7.setupnow reports the timeout as what it is, with the same typed error, and still writes nothing.runConfigurerethrowsRequestTimeoutErrorunchanged, next to theInterruptErrorrethrow, so it keeps itsREQUEST_TIMEOUTcode, exit 7,nextActionandcli_…request id. Before, it fell into the non-ApiErrorbranch, which wrapped it in an exit-3CLIError("API key rejected … did you mean to set TESTSPRITE_API_URL?").API key check against <url> timed out, profile NOT updated: <message>instead of "API key rejected". Nothing is written to the credentials file, as before.ApiErrorfrom/mestill exits 3 with its envelope, and any other unexpected throw keeps the exit-3 wrapper.Related issue
Closes #614
Season 4 CLI Improvement Bonus
Discord username: interferon0
Type of change
Checklist
mainbranch.(
feat(...),fix(...),docs(...), …).npm run lintandnpm run format:checkpass.npm run typecheckpasses.npm testpasses and coverage stays at or above the 80% gate.credentials required).
README.md/DOCUMENTATION.mdwhererelevant.
Notes for reviewers
Tests, in
init.test.tsat thesetup --from-envlevel:requestTimeoutMs: 20:setupthrowsRequestTimeoutErrorwithREQUEST_TIMEOUT, exit 7 and acli_request id, writes no credentials, and stderr says "timed out, profile NOT updated", never "API key rejected". On current main (a18d37c) this test fails withexpected CLIError: API key rejected by https://api… to be an instance of RequestTimeoutError./mestill exits 3 withAUTH_INVALID, itsnextActionand request id. This one is a control and passes before and after.uses requestTimeoutMs for the pre-write key validation pingtest inauth.test.tskeeps passing, sinceRequestTimeoutErroris aCLIError.End to end with the built CLI against a local server that accepts the connection and never answers,
--request-timeout 2 setup --from-env --no-agent --output jsonnow prints the same envelope asproject listagainst that server, and no credentials file is written:On v0.15.0 the same run printed
"code": "CLI_ERROR","requestId": "local"and exited 3.fix(setup): apply TESTSPRITE_REQUEST_TIMEOUT_MS to the pre-write key verification ping #626 (for [Hackathon] setup key verification ignores TESTSPRITE_REQUEST_TIMEOUT_MS #470) changes the import block and the
HttpClientoptions a few lines above this catch. Whichever lands second needs a one-line rebase on theerrors.jsimport.Local run:
npm run lint(0 errors; the warnings are existing unusedeslint-disabledirectives),npm run format:check,npm run typecheck,npm test(122 files, 4800 passed, 2 skipped),npm run test:e2e(10 files, 110 passed, 1 skipped) andnpm run test:coverage(statements 90.1%, branches 85.1%, lines 92.3%).Summary by CodeRabbit