Skip to content

JSON-RPC envelope errors use id:null even when the request id is present #398

Description

@cclabadmin

The Ruby SDK server returns JSON-RPC error responses for several malformed JSON-RPC envelope cases, but those responses use id:null even when the incoming payload contains a concrete request id.

From a JSON-RPC client's perspective, the original request remains pending because no response with the matching id arrives. The server itself remains usable and continues to process subsequent requests.

Tested with:

  • stable release v0.18.0 (3ff237a02c0792bbfbcacef5e37c0c7529c1f2a5)
  • Transports: stdio and Streamable HTTP

To Reproduce

  1. Start a server over stdio or Streamable HTTP.
  2. Complete a normal initialization flow.
  3. Send these requests in isolation:
{"jsonrpc":"1.0","id":3,"method":"ping","params":{}}
{"id":4,"method":"ping","params":{}}
{"jsonrpc":"2.0","id":8,"method":12345,"params":{}}

Expected behavior

For valid JSON payloads where the top-level request id is present and recoverable, it would be helpful for the JSON-RPC error response to preserve that id so clients can correlate the response with the pending request.

Logs

Case Sent Server response
wrong jsonrpc version {"jsonrpc":"1.0","id":3,...} {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request","data":"JSON-RPC version must be 2.0"}}
missing jsonrpc field {"id":4,"method":"ping",...} {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request","data":"JSON-RPC version must be 2.0"}}
method as number {"jsonrpc":"2.0","id":8,"method":12345,...} {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request","data":"Method name must be a string and not start with \"rpc.\""}}

In all three cases, subsequent pings received correct responses — the server remained usable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions