Skip to content

Parse RPC errors as JSON content #929

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

Merged
merged 2 commits into from
May 27, 2021

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented May 26, 2021

Bitcoin Core's JSON RPC server returns errors as HTTP error responses with JSON content in the body. Parse this content as JSON to give a more meaningful error. Otherwise, "binary" is given because the content contains ASCII control characters.

Most of the parsing was already in place, but it was only triggered for OK responses.

jkczyz added 2 commits May 26, 2021 10:51
Return an HTTP error response as a status code and contents. This allows
clients to interpret the response as desired (e.g., the contents as a
JSON-formatted error).
Bitcoin Core's JSON RPC server returns errors as HTTP error responses
with JSON content in the body. Parse this content as JSON to give a more
meaningful error. Otherwise, "binary" is given because the content
contains ASCII control characters.
@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #929 (b2f16ad) into main (f8450a7) will increase coverage by 1.70%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
+ Coverage   90.42%   92.13%   +1.70%     
==========================================
  Files          59       61       +2     
  Lines       30173    37142    +6969     
==========================================
+ Hits        27285    34222    +6937     
- Misses       2888     2920      +32     
Impacted Files Coverage Δ
lightning-block-sync/src/http.rs 93.72% <75.86%> (-1.28%) ⬇️
lightning-block-sync/src/rpc.rs 78.51% <84.61%> (+0.13%) ⬆️
lightning/src/util/ser_macros.rs 93.61% <0.00%> (-3.12%) ⬇️
lightning/src/ln/mod.rs 89.28% <0.00%> (-0.72%) ⬇️
lightning/src/chain/mod.rs 100.00% <0.00%> (ø)
lightning/src/chain/onchaintx.rs 93.68% <0.00%> (ø)
lightning/src/chain/package.rs 92.32% <0.00%> (ø)
lightning/src/util/ser.rs 93.18% <0.00%> (+0.20%) ⬆️
lightning/src/ln/functional_tests.rs 97.75% <0.00%> (+0.68%) ⬆️
lightning/src/util/enforcing_trait_impls.rs 91.27% <0.00%> (+0.89%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8450a7...b2f16ad. Read the comment docs.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to me b2f16ad

@TheBlueMatt TheBlueMatt merged commit 8e7b590 into lightningdevkit:main May 27, 2021
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.

3 participants