Skip to content

fix: validate JSON-RPC response IDs - #591

Closed
Linux2010 wants to merge 2 commits into
a2aproject:mainfrom
Linux2010:codex/validate-jsonrpc-response-id
Closed

Linux2010 wants to merge 2 commits into
a2aproject:mainfrom
Linux2010:codex/validate-jsonrpc-response-id

Conversation

@Linux2010

@Linux2010 Linux2010 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The JSON-RPC clients accept a response even if its ID does not match the generated request ID. A misrouted or incorrect response can therefore be returned to the caller as the result of a different request.

Validate response IDs in v1 and v0.3 compatibility clients, including streaming events, JSON errors returned before streaming, and non-200 JSON-RPC error envelopes. Preserve null-ID error responses when the server could not determine the request ID and retain existing handling for ordinary HTTP middleware errors. Also decode a v0.3 streaming preflight JSON error instead of treating it as an SSE stream.

Validation

  • Added regression coverage for mismatched, missing, null and non-string IDs in normal and streaming responses, plus v0.3 preflight and HTTP middleware error handling.
  • go test ./...
  • go test -race ./a2aclient ./a2acompat/a2av0 ./internal/jsonrpc
  • go vet ./...
  • golangci-lint run ./... (v2.11.4)

Loopback tests used NO_PROXY=localhost,127.0.0.1,::1.

@yarolegovich

Copy link
Copy Markdown
Member

I don't think this is a real issue. Each request gets its own HTTP response or SSE stream, so responses can't be misrouted. The change also breaks errors without an id (common in auth middleware), which now surface as invalid agent response instead of e.g. ErrUnauthenticated.

Please focus on issues a real deployment can hit. Reviewing PRs like this takes our time away from those.

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.

2 participants