Skip to content

fix: surface CCIP-Read gateway error messages - #5614

Merged
jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/ccip-gateway-error-message
Nov 20, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/ccip-gateway-error-message

Conversation

@mortezashojaei

@mortezashojaei mortezashojaei commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

When a CCIP-Read gateway returns a 4xx or 5xx response, ccipRequest drops the gateway's error message and reports only the HTTP status text.

EIP-3668 defines the error body: "If the Content-Type of a 4xx or 5xx response is application/json, it MUST adhere to the following JSON schema", which has a single string message field (example: {"message": "Gateway address not supported."}). ccipRequest instead reads JSON.parse(body).data.error, a shape gateways don't send, so it always falls back to response.statusText.

The common gateway libraries use the spec shape. @chainlink/ccip-read-server responds with { message: "No implementation for function with selector …" } (404), { message: "Invalid request format" } (400) and { message: "Internal server error: …" } (500). @ensdomains/ccip-read-router uses json({ message }, { status }). ethers v6 reads message from the same body.

OffchainLookupError takes its details from this error, so for readContract, call and ENS actions that go through CCIP-Read, users currently see Details: Not Found or Details: Internal Server Error instead of the gateway's explanation. Where the status text is empty (as is common over HTTP/2), the details are likely blank.

This reads message from JSON error bodies, when it is a string, and uses it as the details. Otherwise the details fall back to the status text as before. JSON bodies are parsed exactly as before, and the existing data.error lookup, non-JSON responses, the success path and the URL retry order are unchanged.

  • Added an error: gateway error message test to ccipRequest in src/utils/ccip.test.ts, with a local gateway that returns 404 and {"message":"Gateway address not supported."}. It fails without this change (Details: Not Found).
  • Added a patch changeset.

Checks run:

  • pnpm test --run --project core src/utils/ccip.test.ts -t "ccipRequest": 22 passed, 4 skipped. The offchainLookup tests need Anvil and were not run locally.
  • Coverage of src/utils/ccip.ts for those tests: the new branches are covered.
  • Biome, and tsc on src/utils/ccip.ts. The full pnpm check:types was not run locally because it runs out of memory on my machine.

@vercel

vercel Bot commented Nov 19, 2026

Copy link
Copy Markdown

@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 456f44e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mortezashojaei
mortezashojaei force-pushed the fix/ccip-gateway-error-message branch from 9516aee to 456f44e Compare November 19, 2026 23:00
@jxom
jxom merged commit b4be930 into wevm:main Nov 20, 2026
28 of 35 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
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.

2 participants