Skip to content

Reply with error to JSON-RPC requests the server cannot parse - #2189

Merged
acogoluegnes merged 1 commit into
mainfrom
json-rpc-server-exception-handling
Nov 17, 2026
Merged

acogoluegnes merged 1 commit into
mainfrom
json-rpc-server-exception-handling

Conversation

@acogoluegnes

Copy link
Copy Markdown
Contributor

JsonRpcServer#doCall only caught ClassCastException, whereas JacksonJsonRpcMapper reports invalid requests (malformed JSON, nesting too deep, missing method, unknown procedure, wrong parameter count or type) with other runtime exceptions. Those escaped to RpcServer's main loop, which rejected the message without sending a reply, so the client waited until its timeout, forever by default.

doCall now catches any RuntimeException and sends a 400 error response, as on 5.x.

Also fix JacksonJsonRpcMapper's response parsing, which read the "error" field name instead of its value: the JsonRpcException raised on the client side always had code 0 and a null message.

JsonRpcServer#doCall only caught ClassCastException, whereas
JacksonJsonRpcMapper reports invalid requests (malformed JSON, nesting
too deep, missing method, unknown procedure, wrong parameter count or
type) with other runtime exceptions. Those escaped to RpcServer's main
loop, which rejected the message without sending a reply, so the client
waited until its timeout, forever by default.

doCall now catches any RuntimeException and sends a 400 error response,
as on 5.x.

Also fix JacksonJsonRpcMapper's response parsing, which read the
"error" field name instead of its value: the JsonRpcException raised on
the client side always had code 0 and a null message.
@acogoluegnes acogoluegnes added this to the 6.0.0 milestone Nov 17, 2026
@acogoluegnes
acogoluegnes marked this pull request as ready for review November 17, 2026 09:47
@acogoluegnes
acogoluegnes merged commit af48b5c into main Nov 17, 2026
7 checks passed
@acogoluegnes
acogoluegnes deleted the json-rpc-server-exception-handling branch November 17, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant