Skip to content

fix: handle both JSON-RPC envelope and flat seid responses#63

Merged
bdchatham merged 2 commits intomainfrom
fix/rpc-client-dual-format
Apr 3, 2026
Merged

fix: handle both JSON-RPC envelope and flat seid responses#63
bdchatham merged 2 commits intomainfrom
fix/rpc-client-dual-format

Conversation

@bdchatham
Copy link
Copy Markdown
Contributor

Summary

Regression fix for PR #60. Seid's CometBFT fork returns flat JSON ({"node_info":{...}}) not the standard JSON-RPC envelope ({"jsonrpc":"2.0","result":{...}}). PR #60 assumed all responses are wrapped, causing Client.Get() to return "empty result" for all seid queries.

This broke:

  • Peer discoverydefaultQueryNodeID couldn't parse node IDs → "no reachable peers"
  • await-conditionStatusClient.LatestHeight() couldn't parse block height → polls never resolved

Fix

Client.Get() now handles both formats: if the response has a "result" key, unwrap it (standard CometBFT); otherwise return the body as-is (seid flat format).

Also adds logging in peer discovery when EC2 instances are found but unreachable, preventing silent failures.

Test plan

  • TestClient_Get_UnwrapsEnvelope — standard CometBFT format still works
  • TestClient_Get_FlatJSON_SeidFormat — new test for seid flat format
  • All rpc, shadow, server, engine tests pass

🤖 Generated with Claude Code

bdchatham and others added 2 commits April 3, 2026 15:55
PR #60 assumed all CometBFT RPC endpoints return JSON-RPC envelopes
({"jsonrpc":"2.0","result":{...}}), but seid's CometBFT fork returns
flat JSON ({"node_info":{...}}). This caused Client.Get() to return
"empty result" for all seid queries, breaking peer discovery and
await-condition height polling.

Fix Client.Get() to handle both formats: if the response has a
"result" key, unwrap it (standard CometBFT); otherwise return the
body as-is (seid flat format).

Also add logging in peer discovery when instances are found but
unreachable, preventing silent failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…se test

Use "jsonrpc":"2.0" presence to distinguish JSON-RPC envelopes from
flat seid responses, instead of checking for a "result" key. This
prevents false-positive unwrapping if seid ever returns a flat response
with a top-level "result" data field.

Error checking (env.Error) now only applies inside the JSON-RPC branch.

Added TestClient_Get_FlatJSON_WithResultKey to prove a flat response
containing "result" is returned as-is, not unwrapped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bdchatham bdchatham merged commit 32c1c1a into main Apr 3, 2026
2 checks passed
@bdchatham bdchatham deleted the fix/rpc-client-dual-format branch April 3, 2026 23:01
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.

1 participant