Skip to content

cln-plugin: return rpc error instead of exiting on invalid json input#9350

Open
daywalker90 wants to merge 1 commit into
ElementsProject:masterfrom
daywalker90:cln-plugin-json-relax
Open

cln-plugin: return rpc error instead of exiting on invalid json input#9350
daywalker90 wants to merge 1 commit into
ElementsProject:masterfrom
daywalker90:cln-plugin-json-relax

Conversation

@daywalker90

Copy link
Copy Markdown
Collaborator

CLN is too permissive for serde_json when validating json:

lightning-cli -k myplugin-cmd channels='[123456x1x0]'

is valid for lightning-cli but is actually invalid json (bare token in array).

The cln-plugin decoder would error and end the FramedRead stream, causing the PluginDriver loop to exit, and therefore exiting the plugin itself.

We need to recover the id from the invalid json with a separate parser to return a json rpc error to CLN with the correct id so the rpc command does not hang.

Changelog-None

Fixes: #9345

@daywalker90
daywalker90 requested a review from cdecker as a code owner July 24, 2026 11:51
CLN is too permissive for serde_json when validating json:

`lightning-cli -k myplugin-cmd channels='[123456x1x0]'`

is valid for lightning-cli but is actually invalid json (bare token in array).

The cln-plugin decoder would error and end the FramedRead stream, causing the
PluginDriver loop to exit, and therefore exiting the plugin itself.

We need to recover the id from the invalid json with a separate parser to return a
json rpc error to CLN with the correct id so the rpc command does not hang.

Changelog-None
@daywalker90
daywalker90 force-pushed the cln-plugin-json-relax branch from 215507b to 0313961 Compare July 24, 2026 12:52
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.

cln-plugin: malformed JSON frame on stdin terminates the plugin process

1 participant