Repository navigation
Keep the HTTP status on error responses; release 1.0.2 - #3
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
{"message":"Unauthorized"}, were returned verbatim.successwasundefinedand there was noerror, soresult.error.codethrew a TypeError andresult.error?.codewasundefined. Against the live API, every request with a missing or invalid API key does this in 1.0.1.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/httpStatusCodeinbindist-api-go/client.go):NOT_FOUND, …) andmeta.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.ApiError.httpStatus.TIMEOUT, andNETWORK_ERRORfor network failures or a 2xx response that isn't JSON.updateVersionThe server's schema accepts only
releaseNotes,isEnabledandtotpCode, and strips anything else.isActiveandminimumClientVersionnever had any effect. They are now marked@deprecatedrather 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
homepageURL. After merging, push thev1.0.2tag and the release workflow publishes it.Testing
npm run lint,npm run typecheckandnpm run buildpass.{"error"}, an HTML 502, an empty 429, an empty 418, a 200 envelope, a 200 HTML page and a slow response. Each produced the expectedsuccess,code,messageandhttpStatus. The HTML 502, which used to giveNETWORK_ERROR, now givesserver_errorwith status 502.listApplications()with a missing, malformed or invalid{uuid}.{secret}key:{"message":"Unauthorized"}, with nosuccessand noerror{"success":false,"error":{"code":"unauthorized","message":"Unauthorized","httpStatus":401}}🤖 Generated with Claude Code