fix: handle both JSON-RPC envelope and flat seid responses#63
Merged
fix: handle both JSON-RPC envelope and flat seid responses#63
Conversation
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>
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.
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, causingClient.Get()to return "empty result" for all seid queries.This broke:
defaultQueryNodeIDcouldn't parse node IDs → "no reachable peers"StatusClient.LatestHeight()couldn't parse block height → polls never resolvedFix
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 worksTestClient_Get_FlatJSON_SeidFormat— new test for seid flat format🤖 Generated with Claude Code