Skip to content

clnrest: return an error for an XML root that holds text - #9804

Open
harshitsaini17 wants to merge 1 commit into
ElementsProject:masterfrom
harshitsaini17:fix/clnrest-xml-root-text-panic
Open

harshitsaini17 wants to merge 1 commit into
ElementsProject:masterfrom
harshitsaini17:fix/clnrest-xml-root-text-panic

Conversation

@harshitsaini17

Copy link
Copy Markdown
Contributor

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 clnrest passes.

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.
Copilot AI balanced review requested due to automatic review settings December 5, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

No deployments
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.

2 participants