Skip to content

Fixes - #1365

Open
ehsavoie wants to merge 15 commits into
a2aproject:mainfrom
ehsavoie:fixes
Open

Fixes#1365
ehsavoie wants to merge 15 commits into
a2aproject:mainfrom
ehsavoie:fixes

Conversation

@ehsavoie

Copy link
Copy Markdown
Collaborator

• This PR updates the A2A client transports so tenant routing, interceptor changes, and the request sent over the wire agree. It also makes HTTP client ownership and stream shutdown explicit.
• Routing and request construction. REST, JSON-RPC, and gRPC resolve the v1.0 tenant before ordinary interceptors run. Use ClientRoutingInterceptor.routeTenant() to change it. REST encodes resource IDs as individual path segments and builds list queries from the intercepted request. v0.3 gRPC sends the request returned by the interceptor chain.

• HTTP behavior. Transports validate and normalize endpoints before allocating clients. Closing a REST transport cancels active streams, and transports release the HTTP clients they own. getHttpClient() can return null when no client was supplied. POST redirects require opt-in and are suppressed when an authentication interceptor is configured or a header falls outside the allowlist.

• Security alternatives. The SDK selects the first Agent Card alternative it can satisfy in full, including an anonymous alternative when advertised.

Targeted tests passed for endpoint validation, default-port Host headers over HTTP and HTTPS, stream shutdown, tenant routing, interceptor behavior, and security alternative selection.

Provide canonical endpoint keys and encode individual REST path identifiers. Cover accepted and rejected endpoints and path segments.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Expose provider ownership and add a lifecycle that cancels streams and closes owned clients. Treat CDI-managed clients as shared.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Use the effective protobuf request for query values so cleared filters are omitted consistently.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
@jmesnil
jmesnil self-requested a review November 27, 2026 13:49

@jmesnil jmesnil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is quite long and difficult to review...
I've a preliminary question before I dive into it.

If I understand correctly, multi-tenant agent cards are served at https://{server_domain}/.well-known/{tenant}/agent-card.json.

Why that choice and not the simpler https://{server_domain}/{tenant}/.well-known/agent-card.json with the tenant in the authority/base path and the well-known suffix intact.

Moving the tenant in the authority/base path would simplify the code and avoid the whole normalization issue of the tenant if it's in the middle of the agent card url.

*/
T create(C clientTransportConfig, AgentCard agentCard, AgentInterface agentInterface) throws A2AClientException;

/** @return whether the transport runs the tenant routing interceptor phase */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is very cryptic, I don't understand what this could even mean....

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to fail if the ClientRoutingInterceptor is present and the ClientTransportProvider doesn't support it

* @param tenant supplied tenant identifier
* @return the canonical tenant, or null for an unscoped request
*/
public static @Nullable String canonicalizeTenant(@Nullable String tenant) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verify but this method is only called on the client side of the SDK. There is no canonicalization of the tenant on the server side.

The server side call validateTenant which accepts . and .. according to VALID_TENANT_CHARS.

@ehsavoie

Copy link
Copy Markdown
Collaborator Author

@jmesnil well it was because I still wanted the agent cards under the .well-known/ path element. Didn't seem such a bad idea then :(

Add canonical tenant handling and an explicit routing interceptor phase for supported client transports.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Exercise HTTP and HTTPS Host handling across the built-in clients using local test fixtures.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Defer HTTP client selection until transport creation and share stream
tracking with JSON-RPC. Preserve JSON-RPC completion on close and report
cancellation for interrupted REST streams.

BREAKING CHANGE: getHttpClient() returns null when the HTTP client is
selected by the transport. Closing a REST transport cancels active streams.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Use canonical HTTP endpoint URLs and surface invalid agent endpoints as
client exceptions at provider boundaries.

BREAKING CHANGE: HTTP transport endpoints require URI-compatible hostnames
and unambiguous paths. Canonical request URLs include the default port.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Encode each resource ID as one path segment. In v0.3 push configuration
requests, align the raw protobuf names with the resource in the HTTP path.

BREAKING CHANGE: REST rejects empty or ambiguous resource path segments.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Build list query parameters from the effective protobuf requests, including
interceptor changes to push notification pagination.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Resolve the effective v1.0 tenant once for REST, JSON-RPC, and gRPC.
Use it in the request and validate that ordinary interceptors preserve it.

BREAKING CHANGE: Use ClientRoutingInterceptor.routeTenant to change tenants.
Per-request tenants are normalized and validated. JSON-RPC serializes the
interface tenant when a request omits it.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Honor redirect opt-in for requests with allowlisted headers. Log the first
suppression per transport without printing header values.

BREAKING CHANGE: An authentication interceptor or a header outside the
allowlist disables transport-level POST redirects.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Evaluate Agent Card alternatives in order. Apply credentials for every
scheme in the selected alternative and preserve anonymous alternatives.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Use the protobuf request returned by the interceptor chain for v0.3 calls,
including builder replacements.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Use explicit imports in the transport and response correlation tests.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Use shared port and authority constants for reference and multiversion tests.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>

This branch has not been deployed

No deployments
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