Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle json-rpc failure response as root response object for batched requests #692

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

tadovas
Copy link
Contributor

@tadovas tadovas commented Jun 2, 2023

Situation:
Some public nodes on various chains reply with the following json body for batched requests:

{ 
  "jsonrpc":"2.0",
  "error":{
     "code":0,
     "message":"we can't execute this request"
  },
  "id":null
}

And since batched method expects Vec<Output> as a result, serde_json fails to parse response and returns generic and obfuscated error like failed to deserialize response: invalid type: map, expected a sequence at line 1 column 0

Solution:
Check for json-rpc error object before parsing response as array of outputs and returns appropriate Rpc error. Test to reproduce the issue and verify the fix is added.

@tomusdrw
Copy link
Owner

tomusdrw commented Jun 2, 2023

lgtm, thanks!

@tomusdrw tomusdrw merged commit 2752ded into tomusdrw:master Jun 2, 2023
5 checks passed
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.

None yet

2 participants