Repository navigation
fix(sdk): shared error-message vectors, codes and hint length as TypeScript reads them, sdk 1.31.2, python and go 0.10.2 - #730
Open
kroqdotdev wants to merge 3 commits into
Open
kroqdotdev wants to merge 3 commits into
kroqdotdev wants to merge 3 commits into
Conversation
packages/sdk/conformance/errors.json holds 66 cases of status and raw body with the API's text before any hint, the error code as the TypeScript SDK reads it, and whether a 401 or 404 gets a hint. The TypeScript conformance test writes it and checks the client against it; the Python and Go suites read it from that directory. Each port lists the vectors where it differs on purpose (how it counts the 30-character hint threshold, where it reads a code from), and a listed difference that stops differing fails too. The hand-written tables the vectors now cover are reduced to each SDK's own hint wording. No behaviour change: Python's _plain_error_text and Go's plainErrorText are the existing code moved into a function the tests can call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
…sdk 1.31.2, python and go 0.10.2 Review round 1 on #730. - TypeScript reads `error` as the code wherever it sits in the JSON object, then a `code` field; the leading-key regex is kept only for a body that does not parse. - Python's `_error_code` (behind RateLimitError.code and InvalidCursorError) and Go's unexported code take `error` only when it is a code, never a sentence. - Python and Go count the 30-character hint threshold in UTF-16 units, as TypeScript does (Python with surrogatepass, so a lone surrogate counts as one unit). - The Go conformance test goes through the public client; null-code vectors now assert that no code was read; the divergence lists keep only the `code` field, which Python and Go do not read. - New vectors: a 429 sentence that equals the status words, and a lone surrogate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What
The new
packages/sdk/conformance/errors.jsonkeeps the TypeScript, Python and Go SDKs from drifting apart on how they turn an API error answer into a message and a code. It follows the existing vector pattern.src/__tests__/conformance.test.tswrites the file, checks the TypeScript client against it, and fails when the file is stale. The Python and Go suites read the file from that directory and go through each SDK's public client.Each of the 68 vectors has a status and a raw body. The expected values are:
message: the API's text before any hint the SDK adds (TypeScript'sapiMessage).code: the error code, or null.hinted: whether a 401 or 404 gets the SDK's recovery hint. Only presence is compared; each SDK keeps its own hint wording.The cases cover every rule from #729:
messagewins overerror. A blank, U+FEFF-only or non-stringmessagegives way toerror, and amessagethat is only a code is treated as a code.e404,v2_bad). Values that are not codes: a bare404,not-found,Not_found, non-ASCII, padded, a trailing newline, a sentence that equals the status words.nulland objects without text. Unterminated JSON, HTML and an empty body.codefields, 5xx and 429.Behaviour changes (from round 1 review)
codecomes from the body'serrorwhen it is a code, wherever it sits in the object, else from acodefield. Before, it was read only whenerrorwas the first key. The leading-key regex is kept only for a body that does not parse as JSON. The API always sendserrorfirst, so today's answers do not change._error_code, behindRateLimitError.codeandInvalidCursorError, returns only values that are codes. A 429 with{"error":"Too many requests"}no longer has.code == "Too many requests".surrogatepass, so a lone surrogate counts as one unit instead of raising.code, behinderrors.Is(err, ErrInvalidCursor)and the busy-search check, is set only for a code.release: patch. MCP output does not change for any answer the API sends today, so MCP has no version bump or changelog line.Where the ports still differ, and why
Each port's test lists these by vector name. A listed difference that stops differing fails the test, so the lists stay true.
codefield. Python and Go read the code only fromerror, never from acodefield. This affects{"error":"Polar did not answer","code":"outcome_unknown"}and{"error":"Search busy","code":"search_busy"}.InvalidCursorErrorhas its own message.Other changes
_plain_error_textand Go'splainErrorTextare the existing code moved into a function the tests can call.conformance/README.mdlists the new file.packages/sdk/package.json,SDK_VERSION,PYTHON_SDK_VERSION,GO_SDK_VERSION,pyproject.toml,__init__.py,uv.lockanddoc.go, with one changelog entry on each track.Verified
pnpm --filter @webhooks-cc/sdk test(1009 passed) andtsc --noEmit@webhooks-cc/mcptests (263 passed)lib/changelog.test.tsandscripts(98 passed)uv run pytest(995 passed),ruff check,ruff format --checkandmypygo vet ./...andWHK_CONFORMANCE_REQUIRED=1 go test -race ./...🤖 Generated with Claude Code