Repository navigation
fix(sdk): readable error text when the API answers only a code, sdk 1.31.1 - #729
Conversation
….31.1
A body such as {"error":"not_found"} no longer becomes the error's message.
The TypeScript, Python and Go SDKs say the status in words instead ("Not
found", "Bad request", "Server error", ...) and keep the code where it was
read before (code, InvalidCursorError, RateLimitError.code,
ErrInvalidCursor). The request routes also answer a readable message beside
their not_found code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
@coderabbitai review |
Action performed
|
Review round 1 on #729. A bare-code error now reads as the status in words alone only when the code just names the status (not_found on a 404); otherwise the code follows in brackets ("Bad request (invalid_since)"), the same in the TypeScript, Python and Go SDKs. The unknown-status fallback reads "Request failed with HTTP 410". The share route answers "Request not found" beside not_found, the SDK docs describe the rule, and the "another 400" tests check the code is still in the message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nflict Review round 2 on #729. The endpoint request lists, attachment links, share links, connected agents and Google connection routes answer a readable message beside error "not_found", which stays as it was. The share route's errors carry their whole body in SHARE_ERRORS. MCP tool errors call a 409 "conflict" instead of "validation_error". The SDK docs say `code` holds the code only when it came from `error`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
#728 made the SDKs take an API error's text from the body (
message, elseerror). Routes that answer only a code, such asGET /api/requests/{unknown id}with{"error":"not_found"}, then gavemessage: "not_found"in the SDK and the MCP tools.TypeScript SDK (
mapStatusToError): when the extracted text is a bare code (/^[a-z][a-z0-9_]*$/), the message is the status in words: 400 "Bad request", 401 "Unauthorized", 403 "Forbidden", 404 "Not found", 409 "Conflict", 429 "Too many requests", 5xx "Server error", any other "Request failed with HTTP n". The words stand alone only when the code just names the status (not_foundon a 404,unauthorizedon a 401); otherwise the code follows in brackets, since it says what went wrong: "Bad request (invalid_since)", "Server error (internal_error)", "Request failed with HTTP 410 (expired)". This applies to amessagethat is only a code too. The short-message hint is still added, andcodeis still read from the body.Python SDK (
_error_from_response) and Go SDK (errorFromResponse): the same rule.InvalidCursorError,RateLimitError.codeanderrors.Is(err, ErrInvalidCursor)still read the code.MCP:
get_requeston an unknown id now answersmessage: "Not found"with thelist_requestshint (new test). A 409 now has the tool error codeconflictinstead ofvalidation_error(ToolErrorCodegainsconflict).Web routes: these answer a readable
messagebesideerror: "not_found", which stays as it was so clients matching the code keep working:requests/[id],requests/[id]/raw,requests/[id]/replay,requests/[id]/renderandrequests/[id]/shares: "Request not found"requests/[id]/attachments/[index]: "Request not found" or "Attachment not found"endpoints/[slug]/requestsandendpoints/[slug]/requests/paginated: "Endpoint not found"attachments/[id]/[index](signed links): "Attachment not found"request-shares/[id]: "Share link not found"agent/registrations/[id]: "Connected agent not found"integrations/google/connections/[id]andintegrations/google/pick: "Google connection not found"Each entry in
SHARE_ERRORSin the share route now holds its whole response body.Docs: the error sections of the TypeScript, Python and Go SDK pages describe the rule (and, for TypeScript, that
codestill holds it when it came fromerror).Test fixtures that used a one-word lower-case message (
"y" * 250,"busy") now count as codes, so they were changed to sentences; the "another 400" tests check thatinvalid_qis still in the message.Versions
SDK_VERSION, changelog entry).readable-not-found-errors.json, labelrelease: patch.Checks
pnpm typecheck,pnpm lintandpnpm test(SDK 1016, MCP 263, web 2593) all passuv run pytest(941),ruff check,ruff format --checkandmypyall passgo vet ./...andgo test -race ./...pass🤖 Generated with Claude Code
Summary by CodeRabbit