Skip to content

Keep the HTTP status on error responses; release 1.0.2 - #3

Merged
partouf merged 1 commit into
mainfrom
fix/http-error-status
Nov 16, 2026
Merged

partouf merged 1 commit into
mainfrom
fix/http-error-status

Conversation

@partouf

@partouf partouf commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Error responses

The client parsed every response as JSON and returned it as-is, whatever the HTTP status. For non-2xx responses that weren't the API's error envelope, that went wrong in two ways:

  • Bare JSON bodies, like auth middleware's {"message":"Unauthorized"}, were returned verbatim. success was undefined and there was no error, so result.error.code threw a TypeError and result.error?.code was undefined. Against the live API, every request with a missing or invalid API key does this in 1.0.1.
  • HTML or empty bodies (gateway error pages, some rate limiter responses) failed to parse and came back as NETWORK_ERROR. The HTTP status was lost, so a 502 or 429 looked like the network being down.

The client now works the same way as the Go client (synthesizeError / httpStatusCode in bindist-api-go/client.go):

  • Envelope errors keep the server's code (NOT_FOUND, …) and meta.
  • Other non-2xx responses get a lowercase code built from the status (bad_request, unauthorized, forbidden, not_found, conflict, rate_limited, server_error, http_error). The message comes from a bare {"message"} or {"error"} body, otherwise from the status text.
  • Every non-2xx error carries the new ApiError.httpStatus.
  • Timeout: now also covers reading the response body.
  • Unchanged: 2xx responses, TIMEOUT, and NETWORK_ERROR for network failures or a 2xx response that isn't JSON.

updateVersion

The server's schema accepts only releaseNotes, isEnabled and totpCode, and strips anything else. isActive and minimumClientVersion never had any effect. They are now marked @deprecated rather than removed, so existing code keeps compiling in a patch release. The README example no longer uses them.

Release

Bumps the version to 1.0.2, which also publishes the corrected homepage URL. After merging, push the v1.0.2 tag and the release workflow publishes it.

Testing

  • npm run lint, npm run typecheck and npm run build pass.
  • I ran the built ESM and CJS bundles against a local HTTP server returning: a 404 envelope, a bare-JSON 401, a 403 with {"error"}, an HTML 502, an empty 429, an empty 418, a 200 envelope, a 200 HTML page and a slow response. Each produced the expected success, code, message and httpStatus. The HTML 502, which used to give NETWORK_ERROR, now gives server_error with status 502.
  • Against the live API, listApplications() with a missing, malformed or invalid {uuid}.{secret} key:
    • published 1.0.1 returns {"message":"Unauthorized"}, with no success and no error
    • this branch returns {"success":false,"error":{"code":"unauthorized","message":"Unauthorized","httpStatus":401}}
  • CI passes.

🤖 Generated with Claude Code

…ion fields

Non-2xx responses that aren't the API's error envelope (auth middleware,
rate limiter, gateway HTML pages, empty bodies) failed JSON parsing and
came back as NETWORK_ERROR with the status lost. Now, as in the Go
client, the client builds an error from the status with a lower-case
code (unauthorized, rate_limited, server_error, ...) and takes the
message from a bare {"message"} / {"error"} body when there is one.
Every non-2xx error carries the status in the new ApiError.httpStatus.

The request timeout now also covers reading the response body.

UpdateVersionOptions.isActive and minimumClientVersion are marked
@deprecated: the server's schema strips them, so they never had an
effect. They stay in the type so existing code still compiles.

Release 1.0.2. The release also picks up the corrected homepage URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@partouf
partouf merged commit ae1d06c into main Nov 16, 2026
2 checks passed
@partouf
partouf deleted the fix/http-error-status branch November 17, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant