fix(chainlib): tolerate non-scalar JSON-RPC request ids in id validation#2302
Merged
Conversation
ValidateRequestAndResponseIds parsed the request id before reaching the "null/empty response id" carve-out. A client that sends a non-scalar id (object/array) — invalid per JSON-RPC 2.0, e.g. a .NET CancellationToken serialized into the id — therefore hard-failed with "failed parsing ID", which lavap surfaces as "jsonRPC ID mismatch / insufficient results" plus a cross-provider retry storm, even when the relay itself was fine. Captured against live nodes: Polygon rejects the object id and replies id:null; NEAR accepts it, returns a valid result, and echoes the object id back. Both were being failed. - Check the null/empty/[] response-id carve-out first, before parsing the request id (covers Polygon's id:null rejection). - When either id is non-scalar, compare ids semantically (whitespace/key-order tolerant) instead of erroring (covers NEAR's verbatim echo, preserving the valid response). A genuinely different id is still reported as a mismatch. Scalar id behaviour is unchanged. Root cause is a non-compliant client; this makes lavap surface the node's real response instead of masking it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
avitenzer
previously approved these changes
May 26, 2026
Drives the real ParseMsg -> SendNodeMsg path against a mock node with an object request id, covering both observed node behaviours: a NEAR-like node that echoes the id and returns a valid result (must be returned, not discarded), and a Polygon-like node that rejects with id:null + "invalid request" (must pass through, not become an "ID mismatch" / retry storm). Complements the ValidateRequestAndResponseIds unit test by asserting the full relay outcome. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
avitenzer
approved these changes
May 28, 2026
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.
Problem
ValidateRequestAndResponseIdsparsed the request id (viaIdFromRawMessage, which only accepts string/number/null) before reaching its existing "null/empty response id" carve-out. So when a client sends a non-scalarid(object/array) — invalid per JSON-RPC 2.0 — lavap hard-fails withfailed parsing ID …, which surfaces to the consumer asjsonRPC ID mismatch error → failed relay, insufficient resultsand triggers a cross-provider retry storm, even when the relay itself was fine.Observed in production on Polygon: a .NET client serialized a
CancellationTokeninto theid:Captured against live nodes, the two react differently — and both were being failed:
id:null(correct per spec).This is chain-agnostic: the same failure reproduces on any chain (confirmed by sending an object id to both gateways).
Fix
null/empty/[]response-id carve-out first, before parsing the request id (covers Polygon'sid:nullrejection — the node's owninvalid requestnow passes through instead of a retry storm).The root cause is a non-compliant client (an object
idviolates JSON-RPC 2.0); this change makes lavap surface the node's real response instead of masking it behind an internal "ID mismatch".Verification
TestValidateRequestAndResponseIds_NonScalarId: proven to fail without the change with the exact production error (failed parsing ID … not a string or float (id: {…CancellationToken…})) and pass with it. Covers Polygon (object→null), NEAR (object echo), whitespace tolerance, genuine object mismatch, and unchanged scalar cases.chainlibsuite +go build/go vet/gofmtclean.Relationship to #2301
Separate root cause from #2301 (NEAR
UNKNOWN_BLOCKclassification). This PR addresses the Polygon-reported failure; the two are independent and touch different code paths.🤖 Generated with Claude Code