Repository navigation
Description
Verified against (commit SHA or released version)
commit 988c0355bb05631e9c6c1785e443937ff2a88c0e (main, v0.14.0)
Discord Username / User ID
1149447580477042769
What does this improvement do?
The exit-code table in DOCUMENTATION.md is a scripting contract: 3 means auth, 14 means the client is too old. The single-id forms of test cancel and test delete honour it. So does multi-id test wait, and since #33 (fixing #78, reported by @crypticsaiyan) so does batch test rerun, where "any auth failure escalates the whole batch to exit 3". The two remaining multi-id commands do not:
test cancel <run-a> <run-b>(the multi-id summary path)test delete-batch <id-a> <id-b> --confirm
Each catches every member error other than 404/409 into a generic error row and then throws CLIError(…, 1). A revoked or mistyped key (AUTH_INVALID/AUTH_REQUIRED/AUTH_FORBIDDEN) or a too-old CLI (CLIENT_TOO_OLD) therefore exits 1, the "generic failure" bucket. Under --output json the error envelope says "code": "CLI_ERROR", so a script or agent cannot tell "re-authenticate / upgrade" apart from "something failed on the server". This is exactly the signal the multi-id test wait and batch-rerun paths were fixed to preserve.
Reproduction. A local mock API that answers every request with a typed error envelope stands in for a revoked key, so no account is needed:
// mock.mjs — node mock.mjs <port> <status> <code>
import http from 'node:http';
const [port, status, code] = [Number(process.argv[2]), Number(process.argv[3]), process.argv[4]];
http.createServer((req, res) => {
res.writeHead(status, { 'content-type': 'application/json' });
res.end(JSON.stringify({ error: { code, message: `mock ${code}`, nextAction: '', requestId: 'req_1' } }));
}).listen(port, '127.0.0.1');node mock.mjs 18733 401 AUTH_INVALID &
export TESTSPRITE_API_KEY=sk-user-abcdefghijklmnopqrstuvwxyz0123456789
ts() { testsprite --endpoint-url http://127.0.0.1:18733 "$@" >/dev/null 2>&1; echo "exit=$? $*"; }
ts test cancel run_a
ts test cancel run_a run_b
ts test delete t_a --confirm
ts test delete-batch t_a t_b --confirm
ts test wait run_a run_b --timeout 5Actual output:
exit=3 test cancel run_a
exit=1 test cancel run_a run_b <- expected 3
exit=3 test delete t_a --confirm
exit=1 test delete-batch t_a t_b --confirm <- expected 3
exit=3 test wait run_a run_b --timeout 5
With the mock answering 426 CLIENT_TOO_OLD instead, test cancel run_a exits 14, but test cancel run_a run_b and test delete-batch t_a t_b --confirm both exit 1.
Multi-id test cancel --output json puts this on stderr:
{ "error": { "code": "CLI_ERROR", "message": "2 cancel requests failed: run_a run_b", ... } }
Expected. These two commands should give the same answer for the same batch-wide failure as their single-id forms and the other fan-outs: exit 3 for an auth error and 14 for CLIENT_TOO_OLD. They should also keep printing the per-id summary on stdout as they do today.
Details / implementation notes
Root cause (src/commands/test.ts):
runTestCancel, multi-id loop:rows.push({ runId, status: 'error', error: message }), thenthrow new CLIError(${errorRows.length} cancel request… failed: …, 1).runDeleteBatch:results.push({ testId, status: 'error', error: msg }), thenthrow new CLIError(${failed} deletion… failed. …, 1).
The precedence already exists. src/lib/wait-exit.ts documents auth (3) and CLIENT_TOO_OLD (14) as batch-wide, sitting at the top of WAIT_EXIT_PRIORITY, because "a bad credential / too-old client fails EVERY poll and retrying can never succeed". isAuthCode() in src/lib/errors.ts is the shared classifier.
Proposed change (small, no output-shape change):
- In both loops, keep the caught
ApiErrorbeside its row; the row's printed/JSON shape stays unchanged. - After the summary is printed, if any errored member carries a batch-wide code (
isAuthCode(code)orCLIENT_TOO_OLD), rethrow that member'sApiError. That gives exit 3 or 14 and a typed--output jsonenvelope (AUTH_INVALIDplus itsnextAction), the same as the single-id form. This check runs before the existingnotFound → 4,errors → 1,conflict → 6ordering, which is otherwise left as it is. - Add the new row to the "Exit codes" block in both commands'
--help.
Tests (mock-based, in src/commands/test.cancel.spec.ts and next to the existing runDeleteBatch tests):
- 401 on every id → exit 3, summary still on stdout;
- 426 → exit 14;
- a mix of cancelled + 401 → exit 3;
- the existing notFound/conflict precedence tests unchanged.
Each new test fails on main today.
Out of scope: stopping the loop early after the first auth failure. The other fan-outs don't do that either.
I'd like to work on this once it's triaged.
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
zeshi-du commentedon Oct 20, 2026
Thanks @protonjls for the thorough report and repro. Accepted: in v0.15.0 both multi-id paths fold any error other than not-found/conflict into a generic row and exit 1.
Scope:
test cancelandtest delete-batchinsrc/commands/test.ts.ApiErrorwith its row. After the summary prints, rethrow it (keeps the real code andnextActionin--output json) if any member failed with an auth code (isAuthCode, exit 3), elseCLIENT_TOO_OLD(exit 14). Auth wins, as insrc/lib/wait-exit.ts. Don't callresolveWaitFailure; it promotes other codes.--helpexit-code blocks and DOCUMENTATION.md.Mock tests: 401 -> 3 with summary printed, 426 -> 14, cancelled + 401 -> 3; each must fail on current main. /assign to claim.
protonjls commentedon Oct 20, 2026
/assign
Thanks @zeshi-du. I'll follow that scope: auth wins over
CLIENT_TOO_OLD, noresolveWaitFailure, 1/4/6 and the summary shape unchanged, and help + DOCUMENTATION rows added. I'll rebase onto v0.15.0 first.testsprite-hob commentedon Oct 20, 2026
Assigned to @protonjls. Thanks for taking this on. (2 more slots available.)
Your open assigned issues (1/3):
(none)
fix(test): exit 3/14 from multi-id cancel and delete-batch on a rejec…
fix(test): exit 3/14 from multi-id cancel and delete-batch on a rejec…