Repository navigation
cln-plugin: use -32603 for handler errors and guarantee integer error.code - #9762
Open
daywalker90 wants to merge 1 commit into
Open
daywalker90 wants to merge 1 commit into
daywalker90 wants to merge 1 commit into
Conversation
…ror.code` `parse_error` defaulted to `-32700` (JSON-RPC 2.0 *Parse error*) for all handler errors and panics instead of `-32603` (*Internal error*), and `RpcError` had `code: Option<i32>`, allowing JSON-formatted errors with a missing or `null` `code` (e.g. a forwarded `cln_rpc::RpcError` with `code: None`) to serialize `"code": null`, which violates JSON-RPC 2.0 and is rejected by `lightningd` on `setconfig`. Change `RpcError.code` to `i32`, keep `-32700` in `JsonCodec` for actual JSON parse failures, use `-32603` (`JSONRPC_INTERNAL_ERROR`) as the default in `parse_error`, and deserialize via a local `RawRpcError` with `code: Option<i32>` so JSON error payloads without a code still avoid over-escaping while defaulting to `-32603`. Update `parse_error_includes_full_anyhow_chain` and add unit tests for explicit codes and missing/`null` codes. Changelog-Changed: cln-plugin: use JSON-RPC error code `-32603` (Internal error) instead of `-32700` (Parse error) for plugin handler errors, and never emit `"code": null`.
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.
parse_errordefaulted to-32700(JSON-RPC 2.0 Parse error) for all handler errors and panics instead of-32603(Internal error), andRpcErrorhadcode: Option<i32>, allowing JSON-formatted errors with a missing ornullcode(e.g. a forwardedcln_rpc::RpcErrorwithcode: None) to serialize"code": null, which violates JSON-RPC 2.0 and is rejected bylightningdonsetconfig.Change
RpcError.codetoi32, keep-32700inJsonCodecfor actual JSON parse failures, use-32603(JSONRPC_INTERNAL_ERROR) as the default inparse_error, and deserialize via a localRawRpcErrorwithcode: Option<i32>so JSON error payloads without a code still avoid over-escaping while defaulting to-32603.Update
parse_error_includes_full_anyhow_chainand add unit tests for explicit codes and missing/nullcodes.Changelog-Changed: cln-plugin: use JSON-RPC error code
-32603(Internal error) instead of-32700(Parse error) for plugin handler errors, and never emit"code": null.