Repository navigation
Description
Verified against (commit SHA or released version)
commit 988c035 (v0.14.0)
Discord Username / User ID
interferon0
What does this improvement do?
The CLI assumes nothing sits between it and api.testsprite.com. On a company laptop, in a hotel, or on a self-hosted CI runner, something usually does: a proxy that re-signs HTTPS, a firewall that serves a block page, a captive portal. Three things go wrong there, and each one sends the user (or the coding agent driving the CLI) to fix the wrong thing.
1. Behind a TLS-inspecting proxy, every command fails, even when IT set the machine up correctly. Zscaler, Netskope and antivirus HTTPS scanning re-sign traffic with a root that IT installs in the operating system's certificate store. curl, git and the browser trust it. Node only trusts its bundled Mozilla roots, so every testsprite command fails:
$ SSL_CERT_FILE=corp-ca.pem testsprite --endpoint-url https://127.0.0.1:18203 auth status
Error: fetch failed
Service is temporarily unavailable. The CLI retries with exponential backoff; if this persists, report it.
(exit 10, after 4 attempts)
(SSL_CERT_FILE=corp-ca.pem curl https://127.0.0.1:18203/me answers 200 on the same machine.) Nothing mentions a certificate or NODE_EXTRA_CA_CERTS. The shortcut people reach for, NODE_TLS_REJECT_UNAUTHORIZED=0, turns off certificate checks for the requests that carry the API key.
2. A proxy's block page is read as TestSprite's verdict. When a firewall, captive portal or WAF answers with an HTML page, the CLI maps its status code to an API error code as if TestSprite had said it. Measured with test get test_abc against a server that answers every request with an HTML "Access Denied" page:
| page status | what v0.14.0 tells the user | exit |
|---|---|---|
| 403 | Server returned 403 without an error envelope. (code AUTH_FORBIDDEN) |
3 (auth) |
| 402 | Top up credits on the portal Billing page ... Run testsprite usage to check your current balance |
12 (credits) |
| 404 | Server returned 404 without an error envelope. (code NOT_FOUND) |
4 (not found) |
| 426 | Server returned 426 without an error envelope. (code CLIENT_TOO_OLD) |
14 (upgrade) |
Scripts and coding agents act on the exit code and the error text, so they rotate a working API key, tell the user to buy credits, recreate a test that exists, or upgrade the CLI, for a request TestSprite never received. The page's title, which usually says exactly what happened ("Website blocked by your organization"), is thrown away. testsprite doctor on the same 403 page prints API key rejected (AUTH_FORBIDDEN) and tells the user to mint a new API key with the run:tunnel scope.
3. Every other network failure reads the same. A typo in --endpoint-url, a closed port and a proxy asking for credentials (407) all print fetch failed plus "if this persists, report it", after 4 attempts. testsprite doctor says GET /me failed (UNAVAILABLE) and then blames the endpoint for not supporting tunnels.
Details / implementation notes
Proposed fix, in the shared HTTP layer so every command gets it:
- OS certificate store fallback. When Node rejects the API's chain as untrusted, add the roots that only the OS store has to Node's default CA list (
tls.getCACertificates('system')+tls.setDefaultCACertificates, Node 22.19+ / 24.5+), once per process, and retry at once. Verification stays on. On Node 20 nothing changes. - Pages that are not the API. The API answers errors with JSON: its envelope, or its framework's JSON for an unknown route (
{"message":"Cannot GET ...","error":"Not Found","statusCode":404}) or a body it cannot parse. It also echoes the request'sx-request-id. I checked both against api.testsprite.com. So a 4xx whose body is not JSON at all (HTML, plain text, empty) and that does not echo the request id did not come from the API. Report it as exit 10 withdetails.reason: "not_testsprite", the status, the content type and the page title, and do not retry it. JSON answers, 408/429 and 5xx keep today's handling. - Named causes. Walk the
fetch failedcause chain and name the failure (untrusted, expired or wrong-host certificate, DNS, refused, timeout, reset, proxy refusal), with the fix innextActionanddetails.reason/details.causefor--output json. Certificate failures and a 407 fail on the first attempt.doctorprints the same cause and stops blaming tunnels. - Exit codes for real API answers do not change.
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
fyZhang66 commentedon Oct 20, 2026
Confirmed in part, thanks @Andy00L. The non-JSON 2xx copy is already fixed on dev (it names a proxy, captive portal or login page). Still open: TLS chain errors are reported as a generic transport failure and retried four times, and non-JSON error statuses still map 402/403 to credits/auth. Accepted at low priority, scope:
UNABLE_TO_VERIFY_LEAF_SIGNATURE/SELF_SIGNED_CERT_IN_CHAIN/CERT_HAS_EXPIREDinto a typed error with no retries, whose message namesNODE_EXTRA_CA_CERTS.tls.getCACertificates('system')is not available across our supported Node range).AUTH_FORBIDDEN.No new dependency. Comment
/assignto claim it.OkeyAmy commentedon Oct 20, 2026
/assign
testsprite-hob commentedon Oct 20, 2026
Assigned to @OkeyAmy. Thanks for taking this on. (0 more slots available.)
Your open assigned issues (3/3):
fix(http): name corporate-network transport failures (TestSprite#433)
fix(http): name corporate-network transport failures (TestSprite#433)
fix(http): name corporate-network transport failures (TestSprite#433)
fix(http): narrow the change to TLS/407 and non-JSON 4xx failures
fix(http): name TLS-inspection, proxy 407 and non-API 4xx failures (T…