Skip to content

fix: Fixing small issues and ensuring that the tenant is managed before interceptors - #1365

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

ehsavoie wants to merge 10 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.

@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 :(

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 <[email protected]>
Evaluate Agent Card alternatives in order. Apply credentials for every
scheme in the selected alternative and preserve anonymous alternatives.

Signed-off-by: Emmanuel Hugonnet <[email protected]>
Use the protobuf request returned by the interceptor chain for v0.3 calls,
including builder replacements.

Signed-off-by: Emmanuel Hugonnet <[email protected]>
Use explicit imports in the transport and response correlation tests.

Signed-off-by: Emmanuel Hugonnet <[email protected]>
Exercise HTTP and HTTPS Host handling across the built-in clients using local test fixtures.

Signed-off-by: Emmanuel Hugonnet <[email protected]>
Use shared port and authority constants for reference and multiversion tests.

Signed-off-by: Emmanuel Hugonnet <[email protected]>
@ehsavoie ehsavoie changed the title Fixes fix: Fixing small issues and ensuring that the tenant is managed before interceptors Nov 30, 2026
@ehsavoie

Copy link
Copy Markdown
Collaborator Author

@jmesnil I think we should split this PR in a serie of PRs. WDYT ?
I tried to create a stacked PR but it became a nightmare :(

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