Skip to content

fix: validate JSON-RPC response IDs - #1335

Merged
kabir merged 3 commits into
a2aproject:mainfrom
Linux2010:codex/validate-jsonrpc-response-id
Nov 19, 2026
Merged

kabir merged 3 commits into
a2aproject:mainfrom
Linux2010:codex/validate-jsonrpc-response-id

Conversation

@Linux2010

@Linux2010 Linux2010 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses the v1 path of #1331. The JSON-RPC transport generated an ID internally and discarded it, so it accepted results and errors with a different ID. This is a protocol-consistency check; no real deployment exhibiting cross-request HTTP response misrouting has been established, so its practical value remains a review question.

Generate and retain an ID per call and validate normal responses, SSE events and standard JSON-RPC preflight errors. Preserve explicit null-ID errors when the server cannot identify the request, and leave non-JSON-RPC middleware errors on their existing path. Treat stream errors as terminal, including when an event arrives before the stream future is bound. Update existing fixtures to return the actual request ID.

The shared response parser now accepts an explicit null ID for an error and handles an extended-agent-card error. The v0.3 path is handled separately in #1334.

Validation

  • Confirmed the mismatched-ID GetTask regression before the fix.
  • mvn -q -pl client/transport/jsonrpc -am clean test (682 reactor tests passed).
  • Real HTTP regressions cover concurrent IDs, mismatch, missing and null IDs, SSE and preflight errors. A real TCP test confirms that, with the JDK HTTP client, mismatched ID closes the connection while a valid WORKING event keeps it open; actual Vert.x and Android connection closure was not tested.
  • git diff --check.

Follow-up: JDK 17 CI's NullAway check rejected passing ref.get() to the non-null future binding. The follow-up commit binds the non-null returned future directly, retaining the early-callback cancellation logic. The local JSON-RPC reactor tests passed on JDK 25; JDK 17 CI on the new head remains to be verified.

Follow-up: preserve middleware errors

At head b8b5b3cb, non-2xx JSON-RPC-style error responses without an id retain the existing HTTP error path. A local HTTP server reproduced a regression for an HTTP 429 response: the initial PR replaced its HTTP error with an ID mismatch, whereas the baseline and follow-up preserve the HTTP status, body and Retry-After header. The default JDK client's HTTP 401 path was also checked and was not affected by that regression. Explicit mismatched IDs and HTTP 200/SSE validation retain the PR's prior behavior.

  • The JSON-RPC reactor package passed for 8 modules; its JSON-RPC module ran 56 tests successfully on JDK 25.
  • Targeted Spotless verification passed for the new test file. Repository-wide Spotless, when explicitly enabled, also fails on the unmodified baseline; the existing modified source file had pre-existing formatting violations.
  • git diff --check passed. Remote CI will cover its configured matrix.

@kabir
kabir merged commit 58c7e92 into a2aproject:main Nov 19, 2026
15 checks passed
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.

3 participants