Skip to content

JSON-RPC client accepts responses with an unrelated request ID #1331

Closed

Description

@Linux2010

What happened?

The v1 JSON-RPC transport generates a request ID, but does not retain it when reading and parsing the response. Consequently, a response with an unrelated ID can be returned as the result of the current request.

Reproduced against main 897835ef664fb5c9fc4e1f5388e88a49c93e743c using a local HTTP server: have JSONRPCTransport.getTask send a request and return the existing GET_TASK_TEST_RESPONSE fixture from client/transport/jsonrpc/src/test/.../JsonMessages.java, whose response ID is the fixed cd4c76de-d54c-436c-8b9f-4c2703648d64. The client generates a new random UUID for the request but accepts that response and returns the Task. A regression expecting A2AClientException fails with Expected A2AClientException to be thrown, but nothing was thrown.

JSONRPCTransport.createPostBuilder calls JSONRPCUtils.toJsonRPCRequest(null, ...), which generates an ID internally. unmarshalResponse then parses the response and handles its error/result without comparing IDs. Please also check streaming events, pre-stream errors and the v0.3 client when fixing this; the reproduced case is a successful v1 GetTask response.

This resembles the fixes in a2aproject/a2a-go#591 and a2aproject/a2a-rs#560. A response error with id: null can be legitimate when the server could not determine the request ID, so that case needs distinct handling.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions