Skip to content

feat: reject requests with unsupported A2A-Version - #457

Merged
nahapetyan-serob merged 3 commits into
mainfrom
serob/version-negotiation
Oct 16, 2026
Merged

nahapetyan-serob merged 3 commits into
mainfrom
serob/version-negotiation

Conversation

@nahapetyan-serob

Copy link
Copy Markdown
Contributor

Adds server-side A2A version negotiation. Each transport sets the version it serves on CallContext.ProtocolVersion (1.0 for v1, 0.3 for a2av0 and gRPC v0). InterceptedHandler rejects requests with a different A2A-Version with ErrVersionNotSupported, before interceptors run.

  • A missing header is treated as 0.3 (per spec). Multiple values return InvalidRequest.
  • The v1 HTTP transports also accept A2A-Version as a query parameter.
  • The gRPC agent card RPCs now create a call context, so they are validated too.

Behavior changes:

  • 1.0 endpoints now reject requests without A2A-Version (a2a-go clients MUST send it).
  • In unary methods, the required-extensions and protocol version checks now runs before interceptors, as it already did in streaming methods.

Comment thread a2asrv/intercepted_handler.go Resolved
@nahapetyan-serob
nahapetyan-serob merged commit 4226e74 into main Oct 16, 2026
5 checks passed
@nahapetyan-serob
nahapetyan-serob deleted the serob/version-negotiation branch October 16, 2026 12:25
nahapetyan-serob pushed a commit that referenced this pull request Oct 21, 2026
🤖 I have created a release *beep* *boop*
---


## [2.7.0](v2.6.0...v2.7.0)
(2026-10-21)


### Features

* add input mode validation
([#456](#456))
([8c814be](8c814be))
* extension point for snapshot materialization logic
([#449](#449))
([4899045](4899045))
* reject requests with unsupported A2A-Version
([#457](#457))
([4226e74](4226e74))
* use application/a2a+json with Accept-based negotiation
([#465](#465))
([a8caf47](a8caf47))


### Bug Fixes

* **a2a:** serialize task status timestamps in UTC
([#452](#452))
([b657f33](b657f33))
* decode application/a2a+json error responses in the REST client
([#448](#448))
([3e1aa7f](3e1aa7f))
* **errordetails:** handle nil Value in Typed.MarshalJSON
([#474](#474))
([73c49ac](73c49ac))
* **grpc:** forward next_page_token in push config list responses
([#455](#455))
([7210014](7210014))
* **grpc:** keep caller metadata when attaching service params
([#476](#476))
([f01e895](f01e895))
* honor a2a+json Content Type when Accept is */* or missing
([#468](#468))
([2169266](2169266))
* reject trailing data after the JSON body
([#453](#453))
([e85760e](e85760e))
* **rest:** map non-A2A HTTP error responses by status code
([#471](#471))
([4baba5f](4baba5f))
* return plain error when streaming fails before the first event
([#463](#463))
([cf62533](cf62533))
* **taskstate:** reject unknown task state values on unmarshal and REST
status param ([#404](#404))
([534a60f](534a60f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
yarolegovich pushed a commit that referenced this pull request Nov 2, 2026
…thInterceptor (#479)

## Description

Fixes #478 🦕

### Motivation

`ServiceParams` stores its keys lowercased so that `Get` and `Append`
are case-insensitive, but `interceptBefore` and `AuthInterceptor` write
`A2A-Version`, `Authorization` and the API key name to the map directly,
with their original casing. Interceptors can't read those keys with
`Get`.

If the caller also attaches the version with `AttachServiceParams`, the
map ends up with `a2a-version` and `A2A-Version`, the HTTP transports
send two `A2A-Version` headers, and since #457 the server rejects the
request with `invalid request: 2 protocol versions specified`.

### Changes

| File | Change |
|---|---|
| `a2aclient/middleware.go` | Add an unexported `ServiceParams.set` next
to `Append`: lowercases the key and replaces its values. |
| `a2aclient/client.go` | `interceptBefore` sets the protocol version
with `set`, so it replaces a version attached by the caller instead of
being sent next to it. |
| `a2aclient/auth.go` | `AuthInterceptor` sets `Authorization` and the
API key header with `set`. |

The wire format is unchanged: `Header.Add` canonicalizes header names
and the gRPC transport already lowercases metadata keys.

### Tests

| File | Coverage |
|---|---|
| `a2aclient/client_test.go` |
`TestClient_InterceptorsSeeProtocolVersion`: an interceptor reads the
version with `Get`. `TestClient_AttachedProtocolVersionIsSentOnce`: a
client with the version attached through `AttachServiceParams` gets a
response from a JSON-RPC server instead of `invalid request`.
`TestClient_InterceptorsAttachServiceParams` now expects the
`a2a-version` key. |
| `a2aclient/auth_test.go` | `TestAuthInterceptor` now expects the
`authorization` and `x-custom-auth` keys. |

The new tests fail on `main` and pass with the fix. The rest of the
suite passes unchanged.

If the caller attaches a different version, the client's own version now
wins. a2a-python does the opposite (`setdefault` on the headers), so I
can switch to keeping the caller's value if you prefer that.

---

Happy to adjust the approach!
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