Repository navigation
clnrest: return an error for an XML root that holds text - #9804
Open
harshitsaini17 wants to merge 1 commit into
Open
harshitsaini17 wants to merge 1 commit into
harshitsaini17 wants to merge 1 commit into
Conversation
A request body like <getinfo>hello</getinfo> made request_body_to_rpc_params panic, because the root turns into a JSON string and the unwrap on from_value failed. The body is parsed before the rune is checked, so no auth was needed. Now it returns an error, like the other body formats do. Changelog-Fixed: clnrest: an XML request whose root element holds text, not child elements, now returns an error instead of a panic.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
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.
If you send clnrest an XML body with only text inside, like
<getinfo>hello</getinfo>, it crashes the request with a panic. It also happens with a number, like<getinfo>5</getinfo>. The other body types (JSON, YAML, form) give an error message instead, so this one was missed. A client does not need a rune to send this.Now it gives the same kind of error as the other types. Normal XML, like
<getinfo><id>x</id></getinfo>or<getinfo/>, works as before.I did not check what the panic does to a running node. I think only that one request fails, but I am not sure.
I added 4 tests. The two for text and number fail on master and pass now.
cargo test -p clnrestpasses.