Skip to content

fix(server): enforce A2A-Version on the REST and gRPC bindings - #411

Closed
gulldan wants to merge 6 commits into
a2aproject:mainfrom
gulldan:fix/a2a-version-rest-grpc
Closed

gulldan wants to merge 6 commits into
a2aproject:mainfrom
gulldan:fix/a2a-version-rest-grpc

Conversation

@gulldan

@gulldan gulldan commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #406 → #405 → #407 → #411 → #395. Stacked on #407: review only the last commit.

Fixes #410.

Problem

Only the JSON-RPC binding read A2A-Version. HTTP+JSON and gRPC ran a request with A2A-Version: 99.0, or with no version at all, as a 1.0 request, although §3.6.2 requires every interface to answer VersionNotSupportedError and to read an empty value as 0.3.

Fix

  • check_a2a_version moves unchanged from jsonrpc.rs to middleware.rs and becomes pub, where the A2A 1.1 stack (feat(server)!: add live exchanges with a shared execution runtime #388) also puts it. JSON-RPC behaves exactly as before.
  • rest_router runs it in a route_layer ahead of every REST route. When the header is absent it reads the A2A-Version query parameter, which §3.6.1 lets a client send instead (a2a-go's newHTTPServiceParams does the same). A rejection uses the existing mapping: 400, FAILED_PRECONDITION, ErrorInfo reason VERSION_NOT_SUPPORTED.
  • GrpcHandler runs it on the metadata of all 11 methods before dispatch: FAILED_PRECONDITION with the same ErrorInfo.
  • Tests that call RestTransport, GrpcTransport or rest_router directly now send A2A-Version: 1.0, as fix(a2a-server): fix several SHOULD/MAY-level ACTS conformance gaps #302 did for the JSON-RPC ones. A2AClient already sends it by default.

Behavior change: a REST or gRPC client that sends no A2A-Version is now rejected as 0.3, as JSON-RPC clients have been since #302. The a2a-python and a2a-go clients on main send it on every transport.

Tests

  • rest::tests::test_unsupported_a2a_version_is_rejected (99.0), test_missing_a2a_version_is_rejected (no version, on SendMessage and on GET /tasks/{id}), test_a2a_version_query_parameter_is_accepted (?A2A-Version=1.0 accepted, ?A2A-Version=99.0 rejected).
  • a2a-grpc e2e grpc_transport_rejects_unsupported_a2a_version: SendMessage and SendStreamingMessage with 99.0 and with no version get VERSION_NOT_SUPPORTED through GrpcTransport.
  • With the REST layer and the gRPC calls removed, these four fail (3 + 1); the JSON-RPC tests are unchanged.
  • The reproduction from [Bug]: A2A-Version is checked on JSON-RPC only; HTTP+JSON and gRPC run any version #410 on this branch: HTTP+JSON 400 FAILED_PRECONDITION "version not supported: 99.0" / "…: 0.3", gRPC FailedPrecondition with the same messages, 1.0 served on all three.
  • CI steps on Linux, stable 1.99.1: cargo metadata --locked, cargo hack check --all-targets --each-feature, cargo fmt --check, cargo hack clippy --all-targets --each-feature -- -D warnings, cargo test --workspace --exclude itk-rust-current-agent, copyright headers — all green (842 tests).
  • ITK PR suite (run_itk.sh, a2a-itk main d53108a): 12/12 passed — send message, push notification and resubscribe over JSON-RPC, gRPC and HTTP+JSON, against python_v10, go_v10 and rust_v10 in both directions.

Overlap with the A2A 1.1 stack

#388 adds the same check to REST, gRPC and SLIMRPC on the 1.1 line; this is the 1.0-line change for main and the current releases. Names follow #388 (middleware::check_a2a_version, validate_protocol_version in rest.rs and server.rs), so when the stack rebases the conflicts in those files resolve by taking the stack's side. One difference: #388's REST layer reads only the header, so POST /rest/message:send?A2A-Version=1.0 with no header gets 400 there and 200 here. SLIMRPC is left to #388.

🤖 Generated with Claude Code

The JSON-RPC transport never looked at the status of a response. An
error that something in front of the agent answers itself (an
authenticating proxy's 401, a gateway's 429 or 502) carries no
JSON-RPC envelope, so the caller got "failed to parse JSON-RPC
response" and could not tell a credential or rate-limit problem from
a broken server. A streaming call answered that way without a content
type was handed to the SSE parser and came back as an empty stream.

A body that is not a JSON-RPC envelope is now reported with its
status, as the REST transport already does ("HTTP 429 Too Many
Requests: <body>"); a JSON-RPC envelope is still decoded whatever the
status, and a non-success status is never treated as a stream.

Fixes: a2aproject#404

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
@gulldan
gulldan requested a review from a team as a code owner October 31, 2026 11:28
The streaming test matched on the result and panicked in an `Ok` arm that a
passing run never reaches, so that line stayed uncovered. Taking the error
with `.err().expect()` keeps the assertion and needs no `Debug` on the stream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

muscariello and others added 4 commits October 31, 2026 16:53
google.protobuf.Value carries every number as a double, and
proto_value_to_json_value turned each one back into a JSON float, so
an integer in a data part or in metadata reached the executor, and a
client's decoded response, as 3600.0. serde then refuses it for an
integer type ("invalid type: floating point `3600.0`, expected u32").

A whole number within +-2^53, where a double is exact, is now given
back as an integer; other numbers stay floats. The round-trip tests
that used floats to work around this now use integers, and a new
protojson test decodes a JSON-RPC SendMessage whose data part holds an
integer and deserializes it into u32.

Fixes: a2aproject#399

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
InMemoryTaskStore never removed a task, and TaskStore has no delete,
so a long-running agent kept every task it ever served: 20,000 tasks
with a 4 KiB artifact each held 192 MiB.

InMemoryTaskStore::with_terminal_task_limit(n) keeps at most n tasks
in a terminal state and purges the one that reached its terminal state
earliest. Tasks that are not terminal are never purged, and a purged
task reads as TaskNotFoundError, which A2A 3.3.2 allows for a task
that was completed and purged. new() keeps every task, as before. With
a limit of 1,000 the same run stays at about 20 MiB.

Fixes: a2aproject#401

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
Only the JSON-RPC binding read A2A-Version: HTTP+JSON and gRPC served
a request with `A2A-Version: 99.0`, or with no version at all, as a
1.0 request, although 3.6.2 requires every interface to answer
VersionNotSupportedError and to read an empty value as 0.3.

The JSON-RPC check moves unchanged to middleware::check_a2a_version.
rest_router runs it ahead of every route and, when the header is
absent, reads the A2A-Version query parameter that 3.6.1 allows
instead; GrpcHandler runs it on the metadata of every method. Both
answer with the existing VERSION_NOT_SUPPORTED mapping (400 /
FAILED_PRECONDITION). Tests that call the transports directly now send
the version, as the JSON-RPC ones already do.

Fixes: a2aproject#410

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: gulldan <5641375+gulldan@users.noreply.github.com>
@muscariello

Copy link
Copy Markdown
Member

Superseded by #443, which carries the same commit on an in-repo branch so the stack can be reviewed one commit at a time.

@muscariello muscariello closed this Nov 1, 2026
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.

[Bug]: A2A-Version is checked on JSON-RPC only; HTTP+JSON and gRPC run any version

2 participants