You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: surface relayer/edge error messages on 401 and 403 (0.4.x) (#452)
* fix: surface relayer/edge error messages on 401 and 403
The V2 request engine assumed the reason for auth failures instead of
passing through the message returned by the relayer or an intermediary
(Cloudflare/Kong):
- 401 hardcoded "Unauthorized, missing or invalid Zama Fhevm API Key."
and never read the response body.
- 403 (e.g. a Cloudflare/Kong edge block for a missing x-api-key header)
was not handled at all and surfaced as "Unexpected response status 403",
discarding the body.
Both paths now read the response body (best-effort: relayer JSON
`{ error: { message, label } }`, flat `{ message, label }`, or plain text)
and surface the provided message, falling back to the previous default
only when the body has nothing usable. No public type changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: surface relayer/edge error messages in shared fetch error path
`throwRelayerResponseError` (src/relayer/error.ts) — used by
AbstractRelayerProvider for the keyurl GET on both the V1 and V2 providers,
and by the V1 input-proof path — assumed the reason for a failure and
discarded the response body's message. A 403 edge block (Cloudflare/Kong)
or a 401/404 from Kong therefore surfaced only a generic
"HTTP error! status: <code>".
It now reads the body once (relayer JSON `{ error: { message } }`, flat
`{ message }`, or plain text) and appends the provided message, while still
preserving the parsed body in the error cause.
Tests: V1 401/403 surfacing; the keyurl 404+Kong-body test now asserts the
surfaced "no Route matched with those values" message.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: only surface JSON error messages, not raw text bodies
Relayer/edge (Cloudflare/Kong) errors that carry a message are JSON, so the
best-effort readers now surface a message only when the body parses as JSON.
For non-JSON bodies they leave the previous behaviour unchanged (no appended
text, empty `responseJson` in the cause) — avoiding noise like a plain
"Forbidden"/"Rate Limit" body or an HTML error page leaking into the message.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: drop stale 'falls through' comments after 401 break
The 401 case now ends with an explicit break, so the following 429/404
cases no longer fall through to.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: bump version to 0.4.4
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: fix dead Relayer SDK docs link (404 -> docs.zama.org/protocol)
The /protocol/relayer-sdk-guides section index returns 404 to crawlers
(GitBook SPA), failing the linkspector CI check. Point to the protocol
docs root, which resolves.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: regenerate src/_version.ts for 0.4.4
Run `npm run version` so src/_version.ts matches package.json (was stale
at 0.4.2); it feeds the version string into SDK error messages.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments