Repository navigation
fix(wait): report the real auth error code for --wait auth failures - #592
Conversation
Pass the member error's catalog code through CLIError in resolveWaitFailure's auth branch so the JSON error envelope and telemetry classify --wait auth failures with the real auth code instead of the generic CLI_ERROR bucket.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Preserve authentication error codes src/lib/wait-exit.ts, src/lib/wait-exit.test.ts |
resolveWaitFailure passes the member’s authentication code to CLIError. Tests verify that AUTH_INVALID and AUTH_REQUIRED remain classified as authentication errors. |
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Low
Merge Risk: 
Minimal · previous review ecf10
-
The authentication error-code change is ready to merge based on the supplied review evidence.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#398requires the batch--waitauth branch to preserve the member auth code, exit with code 3, and keep the auth message and telemetry classification consistent.src/lib/wait-exit.tsnow passesauthErr.error.codetoCLIErrorwhile retaining exit code 3 and the auth code in the message.src/lib/wait-exit.test.tschecksAUTH_INVALID,AUTH_REQUIRED, exit code 3, the auth message, and telemetry classification.
Full details: Out of Scope Changes check
-
Explanation
The reviewed changes are limited to the
resolveWaitFailure()auth error construction and focused tests insrc/lib/wait-exit.test.ts. The tests directly verify the behavior required by issue#398. No unrelated product behavior or unrelated files are identified.
-
Finishing Touches
-
Fix failing CI checks
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: TestSprite/testsprite-cli/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
de069264-7ab5-417a-8b91-58fd4f7e2e77
📒 Files selected for processing: 2
-
src/lib/wait-exit.test.ts
src/lib/wait-exit.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: TestSprite/testsprite-cli/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
de069264-7ab5-417a-8b91-58fd4f7e2e77
📒 Files selected for processing: 2
-
src/lib/wait-exit.test.tssrc/lib/wait-exit.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
|
🏆 Season 4 CLI Improvement Bonus: entry recorded. Thanks, @tujack39! 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. |
Season 4 CLI Improvement Bonus
Discord username: johnlu1976
Closes #398
Problem
When a
--waitfan-out (test run --all/test rerun/testlist run)fails because a member poll hit an auth error,
resolveWaitFailure()(
src/lib/wait-exit.ts) builds the process-level error asnew CLIError(message, 3)without passing a code.CLIError.codethereforedefaults to the generic, out-of-catalog
'CLI_ERROR'bucket, so:--output jsonprintserror.code: "CLI_ERROR"even though the processexits 3 (auth, per the documented exit-code table) and the message itself
says
auth error (AUTH_...): ...;errorCode(viaclassifyCliError, which readserr.code)is misclassified the same way.
Agents and CI that branch on
error.codeto decide whether to re-authcannot do so for this path — the one failure where re-auth is exactly the
right response. Every other branch of
resolveWaitFailurealready surfacesa faithful code (typed operational errors are routed through
ApiError.fromEnvelope); the auth branch was the odd one out.Fix
Pass the member's real catalog code through
CLIError's existingcodeconstructor parameter:
authErris selected viaisAuthCode(), which is derived from the singleexitCodeFormapping, soauthErr.error.codeis guaranteed to be one ofAUTH_REQUIRED/AUTH_INVALID/AUTH_FORBIDDEN— the exit-3 family,consistent with the hardcoded exit code and with the code already named in
the message. Envelope
error.code, telemetryerrorCode, exit code, andmessage now all agree.
Tests
src/lib/wait-exit.test.ts:f.code === 'AUTH_INVALID'.CLI_ERROR": asserts the returned
CLIErrorcarriescode === 'AUTH_REQUIRED'and thatclassifyCliError(f).errorCode(the telemetry path) reports the same.
Both assertions fail on the pre-fix code with
expected 'CLI_ERROR' to be 'AUTH_INVALID'/'AUTH_REQUIRED'(verified by reverting the fix locally).
Verification (local, Node v24.20.0)
npm test— 396 files passed, 7056 tests passed, 26 skipped, 0 failed.npm run typecheck— clean.npm run lint— 0 errors (215 pre-existing warnings, none in thechanged files);
check-ticket-refsclean.npm run format:check— all files pass Prettier.npm run test:coverage— the changed filesrc/lib/wait-exit.tsis at100% statements / 100% lines / 100% functions (84.5% branches) under its
test file. Note: the full coverage run in this sandbox shows 6 failing
tests in
doctor.test.ts/test.test.ts/secret-file.test.ts— allPOSIX chmod/EACCES cases that fail because the sandbox runs as root
(root bypasses file-permission checks). Verified pre-existing: the same
tests fail identically on the pristine tree with this change stashed,
and none of them touch the
--waitpath.Hackathon S4
Summary by CodeRabbit
Bug Fixes
Tests