This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new a03956cfb7d5 CAMEL-28107: Fix caching and card binding for A2A 
discovery (#31364)
a03956cfb7d5 is described below

commit a03956cfb7d5d9f142a2fecd4509b149528ac62c
Author: Luigi De Masi <[email protected]>
AuthorDate: Sat Dec 5 17:44:55 2026 +0100

    CAMEL-28107: Fix caching and card binding for A2A discovery (#31364)
    
    Request-derived discovery responses of a plain-name A2A consumer now send
    Vary: *, so a cache must revalidate before reuse (the Cache-Control: 
no-store
    set on the exchange was removed by the default HTTP header filters). The 
HTTP
    tests check the headers the client receives on a card response and on a
    discovery error.
    
    The component merges the card declarations once and applies the default
    interface separately for each endpoint role. For a legacy card URL on a
    JSON-RPC endpoint, ${a2a:card} reads the consumer card directly and reports
    JSON-RPC; producers and getResolvedCard() keep the HTTP+JSON fallback. The
    upgrade guide explains when a proxy or wildcard bind address needs a 
publicly
    reachable supportedInterfaces entry.
    
    _Generated by OpenAI Codex on behalf of Luigi De Masi (@luigidemasi)_
    
    Co-authored-by: OpenAI Codex <[email protected]>
    Signed-off-by: Luigi De Masi <[email protected]>
---
 .../apache/camel/catalog/docs/a2a-component.adoc   |  2 +-
 .../apache/camel/catalog/docs/a2a-consumer.adoc    |  6 +++--
 .../camel-a2a/src/main/docs/a2a-component.adoc     |  2 +-
 .../camel-a2a/src/main/docs/a2a-consumer.adoc      |  6 +++--
 .../apache/camel/component/a2a/A2AConsumer.java    | 18 +++++++------
 .../apache/camel/component/a2a/A2AEndpoint.java    | 27 ++++++++-----------
 .../component/a2a/card/AgentCardResolver.java      |  7 ++++-
 .../a2a/simple/A2ASimpleExpressionBuilder.java     |  2 +-
 .../a2a/A2AConsumerHttpIntegrationTest.java        | 30 ++++++++++++++++++----
 .../camel/component/a2a/A2AConsumerTest.java       |  4 +--
 .../component/a2a/A2AEndpointLifecycleTest.java    | 29 +++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_25.adoc    | 10 ++++++--
 12 files changed, 100 insertions(+), 43 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-component.adoc
index 214bd2669e0c..77bf566abf10 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-component.adoc
@@ -174,7 +174,7 @@ The component registers custom Simple language functions 
under the `a2a:` namesp
 | Legacy draft `security` field as JSON array string.
 |===
 
-The `${a2a:card}` functions resolve the agent card from the exchange context. 
On a consumer route, `exchange.getFromEndpoint()` provides the agent's own 
card. On a producer route, the component scans registered endpoints for a 
cached remote card. Returns an empty string if no card is available.
+The `${a2a:card}` functions resolve the agent card from the exchange context. 
On a consumer route, `exchange.getFromEndpoint()` provides the agent's own 
card. A legacy `url` uses the consumer's configured binding. An interface 
derived from a discovery request is specific to that HTTP response. On a 
producer route, the component scans registered endpoints for a cached remote 
card. Returns an empty string if no card is available.
 
 NOTE: The card functions support flat field access only — nested property 
access like `${a2a:card.skills[0].name}` or `${a2a:card.provider.organization}` 
is not supported. For structured data, use `${a2a:card.skills.json}` or 
`${a2a:card}` (full JSON) and parse downstream.
 
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-consumer.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-consumer.adoc
index 6d27c50cfec7..2fd046a20a1b 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-consumer.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/a2a-consumer.adoc
@@ -131,9 +131,11 @@ from("a2a:my-agent?name=My Agent&description=A simple 
agent&version=1.0.0&valida
 ----
 ====
 
-The consumer serves the card at `/.well-known/agent-card.json` under its 
`basePath`. When the file or bean card declares no interfaces, the consumer 
advertises its configured `protocolBinding` and A2A protocol version. The 
generated interface URL uses the scheme, host, port, and mount path seen by the 
HTTP server on the discovery request. A legacy card's top-level `url`, when 
set, supplies the interface URL instead.
+The consumer serves the card at `/.well-known/agent-card.json` under its 
`basePath`. URI parameters configure the agent's identity. To customize 
capabilities, skills, security schemes, supported interfaces, or other card 
metadata, use a card file or an `agentCard` bean.
 
-If clients use a different address, for example behind a reverse proxy or with 
a client that requires a DNS hostname, declare the public URL, binding, and 
protocol version in `supportedInterfaces` in the file or bean card. The 
consumer serves declared interfaces even when the transport supplies no usable 
request URL. Without a configured address, such a request returns HTTP 400.
+When the card declares no interfaces, the consumer advertises its configured 
`protocolBinding` and A2A protocol version. It uses the legacy top-level `url` 
if present. Otherwise it derives the interface URL from the discovery URL 
supplied by the HTTP transport, including the mount path. For example, 
`netty-http` builds that URL from its configured host and port for requests 
with a relative request target. A wildcard bind address such as `0.0.0.0` is 
unsuitable for clients.
+
+If the transport URL differs from the client-facing URL, declare the public 
URL, binding, and protocol version in `supportedInterfaces` in the file or bean 
card. This applies when a reverse proxy rewrites the host or path or terminates 
TLS. The A2A consumer does not interpret `Forwarded` or `X-Forwarded-*` headers 
itself. Declared interfaces are served even when the transport supplies no 
usable request URL. Without a configured address, such a request returns HTTP 
400.
 
 === JSON-RPC Protocol Binding
 
diff --git a/components/camel-ai/camel-a2a/src/main/docs/a2a-component.adoc 
b/components/camel-ai/camel-a2a/src/main/docs/a2a-component.adoc
index 214bd2669e0c..77bf566abf10 100644
--- a/components/camel-ai/camel-a2a/src/main/docs/a2a-component.adoc
+++ b/components/camel-ai/camel-a2a/src/main/docs/a2a-component.adoc
@@ -174,7 +174,7 @@ The component registers custom Simple language functions 
under the `a2a:` namesp
 | Legacy draft `security` field as JSON array string.
 |===
 
-The `${a2a:card}` functions resolve the agent card from the exchange context. 
On a consumer route, `exchange.getFromEndpoint()` provides the agent's own 
card. On a producer route, the component scans registered endpoints for a 
cached remote card. Returns an empty string if no card is available.
+The `${a2a:card}` functions resolve the agent card from the exchange context. 
On a consumer route, `exchange.getFromEndpoint()` provides the agent's own 
card. A legacy `url` uses the consumer's configured binding. An interface 
derived from a discovery request is specific to that HTTP response. On a 
producer route, the component scans registered endpoints for a cached remote 
card. Returns an empty string if no card is available.
 
 NOTE: The card functions support flat field access only — nested property 
access like `${a2a:card.skills[0].name}` or `${a2a:card.provider.organization}` 
is not supported. For structured data, use `${a2a:card.skills.json}` or 
`${a2a:card}` (full JSON) and parse downstream.
 
diff --git a/components/camel-ai/camel-a2a/src/main/docs/a2a-consumer.adoc 
b/components/camel-ai/camel-a2a/src/main/docs/a2a-consumer.adoc
index 6d27c50cfec7..2fd046a20a1b 100644
--- a/components/camel-ai/camel-a2a/src/main/docs/a2a-consumer.adoc
+++ b/components/camel-ai/camel-a2a/src/main/docs/a2a-consumer.adoc
@@ -131,9 +131,11 @@ from("a2a:my-agent?name=My Agent&description=A simple 
agent&version=1.0.0&valida
 ----
 ====
 
-The consumer serves the card at `/.well-known/agent-card.json` under its 
`basePath`. When the file or bean card declares no interfaces, the consumer 
advertises its configured `protocolBinding` and A2A protocol version. The 
generated interface URL uses the scheme, host, port, and mount path seen by the 
HTTP server on the discovery request. A legacy card's top-level `url`, when 
set, supplies the interface URL instead.
+The consumer serves the card at `/.well-known/agent-card.json` under its 
`basePath`. URI parameters configure the agent's identity. To customize 
capabilities, skills, security schemes, supported interfaces, or other card 
metadata, use a card file or an `agentCard` bean.
 
-If clients use a different address, for example behind a reverse proxy or with 
a client that requires a DNS hostname, declare the public URL, binding, and 
protocol version in `supportedInterfaces` in the file or bean card. The 
consumer serves declared interfaces even when the transport supplies no usable 
request URL. Without a configured address, such a request returns HTTP 400.
+When the card declares no interfaces, the consumer advertises its configured 
`protocolBinding` and A2A protocol version. It uses the legacy top-level `url` 
if present. Otherwise it derives the interface URL from the discovery URL 
supplied by the HTTP transport, including the mount path. For example, 
`netty-http` builds that URL from its configured host and port for requests 
with a relative request target. A wildcard bind address such as `0.0.0.0` is 
unsuitable for clients.
+
+If the transport URL differs from the client-facing URL, declare the public 
URL, binding, and protocol version in `supportedInterfaces` in the file or bean 
card. This applies when a reverse proxy rewrites the host or path or terminates 
TLS. The A2A consumer does not interpret `Forwarded` or `X-Forwarded-*` headers 
itself. Declared interfaces are served even when the transport supplies no 
usable request URL. Without a configured address, such a request returns HTTP 
400.
 
 === JSON-RPC Protocol Binding
 
diff --git 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AConsumer.java
 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AConsumer.java
index e7abdfbce816..48b3e6a986f6 100644
--- 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AConsumer.java
+++ 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AConsumer.java
@@ -135,7 +135,7 @@ public class A2AConsumer extends DefaultConsumer {
     protected void doStart() throws Exception {
         super.doStart();
 
-        AgentCard card = getEndpoint().getResolvedCard();
+        AgentCard card = getEndpoint().getConsumerCard();
         String agentName = card != null ? card.getName() : "unknown";
         LOG.debug("A2A Consumer starting for agent: {}", agentName);
 
@@ -513,7 +513,7 @@ public class A2AConsumer extends DefaultConsumer {
                         
exchange.getMessage().setHeader(A2AConstants.EXTENSIONS, extensionUris);
                     }
                     A2AUserProfile profile = getEndpoint().getAuthHandler()
-                            .validateConsumerAuth(exchange, 
getEndpoint().getResolvedCard());
+                            .validateConsumerAuth(exchange, 
getEndpoint().getConsumerCard());
                     if (profile != null) {
                         exchange.setProperty(A2AConstants.USER_PROFILE, 
profile.asMap());
                     }
@@ -608,7 +608,7 @@ public class A2AConsumer extends DefaultConsumer {
     }
 
     private Map<String, AgentExtension> supportedExtensionDeclarations() {
-        AgentCard card = getEndpoint().getResolvedCard();
+        AgentCard card = getEndpoint().getConsumerCard();
         if (card == null || card.getCapabilities() == null || 
card.getCapabilities().getExtensions() == null) {
             return Map.of();
         }
@@ -962,7 +962,8 @@ public class A2AConsumer extends DefaultConsumer {
         Object requestUrl = exchange.getMessage().getHeader(Exchange.HTTP_URL);
         filterInboundHeaders(exchange);
         if (card.getSupportedInterfaces().isEmpty()) {
-            exchange.getMessage().setHeader(CACHE_CONTROL_HEADER, "no-store");
+            // The transport URL can vary per request. Use Vary because the 
default HTTP filters strip outbound Cache-Control.
+            exchange.getMessage().setHeader("Vary", "*");
             URI discovery = 
exchange.getContext().getTypeConverter().tryConvertTo(URI.class, exchange, 
requestUrl);
             if (!isUsableDiscoveryUrl(discovery)) {
                 writeRestError(exchange, 400, "InvalidParamsError",
@@ -986,12 +987,13 @@ public class A2AConsumer extends DefaultConsumer {
                 || !("http".equalsIgnoreCase(discovery.getScheme()) || 
"https".equalsIgnoreCase(discovery.getScheme()))) {
             return false;
         }
+        URI server = discovery;
         String authority = discovery.getRawAuthority();
         if (discovery.getHost() == null && authority != null && 
authority.contains("_")) {
             // Validate service aliases with the JDK's DNS host parser, 
keeping the original authority in the card.
-            discovery = URI.create("//" + authority.replace('_', 'x'));
+            server = URI.create("//" + authority.replace('_', 'x'));
         }
-        return discovery.getHost() != null && discovery.getRawUserInfo() == 
null && discovery.getPort() <= 65535;
+        return server.getHost() != null && server.getRawUserInfo() == null && 
server.getPort() <= 65535;
     }
 
     void handleSendMessage(Exchange exchange) throws Exception {
@@ -2002,7 +2004,7 @@ public class A2AConsumer extends DefaultConsumer {
     }
 
     private String resolveWwwAuthenticate() {
-        AgentCard card = getEndpoint().getResolvedCard();
+        AgentCard card = getEndpoint().getConsumerCard();
         if (card != null && card.getSecuritySchemes() != null) {
             for (SecurityScheme scheme : card.getSecuritySchemes().values()) {
                 String type = scheme.getType();
@@ -2018,7 +2020,7 @@ public class A2AConsumer extends DefaultConsumer {
     }
 
     private boolean isCapabilityEnabled(String capability) {
-        AgentCard card = getEndpoint().getResolvedCard();
+        AgentCard card = getEndpoint().getConsumerCard();
         if (card == null || card.getCapabilities() == null) {
             return false;
         }
diff --git 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AEndpoint.java
 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AEndpoint.java
index 4a1610e499d4..67e45a054637 100644
--- 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AEndpoint.java
+++ 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AEndpoint.java
@@ -23,7 +23,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.camel.Category;
 import org.apache.camel.Consumer;
@@ -162,8 +161,8 @@ public class A2AEndpoint extends DefaultEndpoint {
     @UriParam
     private A2AConfiguration configuration;
 
-    private final AtomicReference<AgentCard> resolvedCard = new 
AtomicReference<>();
-    private AgentCard consumerCard;
+    private volatile AgentCard resolvedCard;
+    private volatile AgentCard consumerCard;
     private A2AProtocol protocol;
     private A2ATaskStore taskStore;
     private boolean taskStoreOwned;
@@ -217,18 +216,10 @@ public class A2AEndpoint extends DefaultEndpoint {
             AgentCard fileCard = loader.load(agentCardSource);
 
             // 2. Resolve card with layered precedence: file < bean < URI 
params
-            AgentCard declared = AgentCardResolver.merge(
-                    fileCard,
-                    configuration.getAgentCard(),
-                    agentCardSource,
-                    configuration.getName(),
-                    configuration.getDescription(),
-                    configuration.getVersion());
-
-            // A legacy URL on a remote card retains its REST fallback. We 
know the binding of our own consumer.
-            resolvedCard.set(AgentCardResolver.withDefaultInterface(declared, 
declared.getUrl(), A2AConstants.PROTOCOL_REST));
-            consumerCard
-                    = AgentCardResolver.withDefaultInterface(declared, 
declared.getUrl(), configuration.getProtocolBinding());
+            AgentCard declared = AgentCardResolver.merge(fileCard, 
configuration.getAgentCard(), agentCardSource,
+                    configuration.getName(), configuration.getDescription(), 
configuration.getVersion());
+            resolvedCard = AgentCardResolver.withDefaultInterface(declared, 
A2AConstants.PROTOCOL_REST);
+            consumerCard = AgentCardResolver.withDefaultInterface(declared, 
configuration.getProtocolBinding());
 
             // 3. Create protocol
             // TODO: Consider a registry-based ProtocolFactory when a third 
protocol binding is added.
@@ -315,11 +306,13 @@ public class A2AEndpoint extends DefaultEndpoint {
         return configuration;
     }
 
+    /** The resolved card used by producers, including the REST fallback for a 
legacy URL. */
     public AgentCard getResolvedCard() {
-        return resolvedCard.get();
+        return resolvedCard;
     }
 
-    AgentCard getConsumerCard() {
+    /** The local card with the binding configured on the consumer. */
+    public AgentCard getConsumerCard() {
         return consumerCard;
     }
 
diff --git 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/card/AgentCardResolver.java
 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/card/AgentCardResolver.java
index 86c04b8fbe6a..374e9d32d77c 100644
--- 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/card/AgentCardResolver.java
+++ 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/card/AgentCardResolver.java
@@ -65,7 +65,7 @@ public final class AgentCardResolver {
             String nameParam, String descriptionParam, String versionParam) {
 
         AgentCard card = merge(fileCard, beanCard, agentCardSource, nameParam, 
descriptionParam, versionParam);
-        return withDefaultInterface(card, card.getUrl(), 
A2AConstants.PROTOCOL_REST);
+        return withDefaultInterface(card, A2AConstants.PROTOCOL_REST);
     }
 
     /** Merge and validate the card before applying a transport-specific 
interface default. */
@@ -184,6 +184,11 @@ public final class AgentCardResolver {
         }
     }
 
+    /** Use the card's legacy URL with the supplied binding when it has no 
declared interfaces. */
+    public static AgentCard withDefaultInterface(AgentCard card, String 
protocolBinding) {
+        return withDefaultInterface(card, card.getUrl(), protocolBinding);
+    }
+
     /** Supply an interface only when the card author did not declare one. */
     public static AgentCard withDefaultInterface(AgentCard card, String url, 
String protocolBinding) {
         if (!card.getSupportedInterfaces().isEmpty() || isBlank(url)) {
diff --git 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/simple/A2ASimpleExpressionBuilder.java
 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/simple/A2ASimpleExpressionBuilder.java
index 78943cb94993..d561ff5be38d 100644
--- 
a/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/simple/A2ASimpleExpressionBuilder.java
+++ 
b/components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/simple/A2ASimpleExpressionBuilder.java
@@ -159,7 +159,7 @@ public final class A2ASimpleExpressionBuilder {
     private static AgentCard resolveCard(Exchange exchange) {
         Endpoint from = exchange.getFromEndpoint();
         if (from instanceof A2AEndpoint a2aFrom) {
-            AgentCard card = a2aFrom.getResolvedCard();
+            AgentCard card = a2aFrom.getConsumerCard();
             if (card != null) {
                 return card;
             }
diff --git 
a/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerHttpIntegrationTest.java
 
b/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerHttpIntegrationTest.java
index ef364f7c9dfc..f8b88dcdde15 100644
--- 
a/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerHttpIntegrationTest.java
+++ 
b/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerHttpIntegrationTest.java
@@ -111,31 +111,51 @@ class A2AConsumerHttpIntegrationTest {
                 HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
     }
 
-    @Test
-    void agentCardEndpoint() throws Exception {
+    @ParameterizedTest
+    @ValueSource(strings = { "", "/agents/stock" })
+    void restDiscoveryAdvertisesMountPath(String mountPath) throws Exception {
         context = createContext();
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() {
-                
from("a2a:test-agent?name=TestAgent&version=1.0.0&description=Integration+test+agent")
+                
from("a2a:test-agent?name=TestAgent&version=1.0.0&description=Integration+test+agent&basePath="
 + mountPath)
                         .setBody(constant("echo"));
             }
         });
         context.start();
 
-        HttpResponse<String> response = get("/.well-known/agent-card.json");
+        HttpResponse<String> response = get(mountPath + 
"/.well-known/agent-card.json");
 
         assertThat(response.statusCode()).isEqualTo(200);
+        assertThat(response.headers().allValues("Vary")).contains("*");
         JsonNode card = MAPPER.readTree(response.body());
         assertThat(card.get("name").asString()).isEqualTo("TestAgent");
         assertThat(card.get("version").asString()).isEqualTo("1.0.0");
         JsonNode interfaces = card.get("supportedInterfaces");
         assertThat(interfaces.size()).isOne();
-        
assertThat(interfaces.get(0).get("url").asString()).isEqualTo(baseUrl());
+        
assertThat(interfaces.get(0).get("url").asString()).isEqualTo(baseUrl() + 
mountPath);
         
assertThat(interfaces.get(0).get("protocolBinding").asString()).isEqualTo("HTTP+JSON");
         
assertThat(interfaces.get(0).get("protocolVersion").asString()).isEqualTo("1.0");
     }
 
+    @Test
+    void discoveryErrorVariesWithRequestUrl() throws Exception {
+        context = createContext();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                
from("a2a:test-agent?protocolBinding=JSONRPC").setBody(constant("echo"));
+            }
+        });
+        context.start();
+
+        // Vert.x also dispatches the trailing slash to the card handler.
+        HttpResponse<String> response = get("/.well-known/agent-card.json/");
+        assertThat(response.statusCode()).isEqualTo(400);
+        
assertThat(MAPPER.readTree(response.body()).get("error").get("message").asString()).contains("supportedInterfaces");
+        assertThat(response.headers().allValues("Vary")).contains("*");
+    }
+
     @Test
     void discoveryPreservesDeclaredInterfaces() throws Exception {
         context = createContext();
diff --git 
a/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerTest.java
 
b/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerTest.java
index 6a4fda4a667c..768384a4cb2e 100644
--- 
a/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerTest.java
+++ 
b/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AConsumerTest.java
@@ -125,7 +125,7 @@ class A2AConsumerTest {
     }
 
     @Test
-    void handleAgentCardReturnsCard() throws Exception {
+    void discoveryUsesLegacyUrlWithConsumerBinding() throws Exception {
         // Create configuration
         A2AConfiguration config = new A2AConfiguration();
         config.setName("Test Agent");
@@ -182,7 +182,6 @@ class A2AConsumerTest {
         AgentCard card = 
OBJECT_MAPPER.readValue(exchange.getMessage().getBody(byte[].class), 
AgentCard.class);
         
assertThat(card.getSupportedInterfaces()).extracting(SupportedInterface::getUrl)
                 .containsExactly("http://my_agent:8080/stock/";);
-        
assertThat(exchange.getMessage().getHeader("Cache-Control")).isEqualTo("no-store");
     }
 
     @ParameterizedTest
@@ -202,7 +201,6 @@ class A2AConsumerTest {
         
assertThat(exchange.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE)).isEqualTo(400);
         JsonNode response = 
OBJECT_MAPPER.readTree(exchange.getMessage().getBody(byte[].class));
         
assertThat(response.get("error").get("message").asString()).contains("supportedInterfaces");
-        
assertThat(exchange.getMessage().getHeader("Cache-Control")).isEqualTo("no-store");
     }
 
     @Test
diff --git 
a/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AEndpointLifecycleTest.java
 
b/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AEndpointLifecycleTest.java
index d28ab3f2efb9..fd78e096caeb 100644
--- 
a/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AEndpointLifecycleTest.java
+++ 
b/components/camel-ai/camel-a2a/src/test/java/org/apache/camel/component/a2a/A2AEndpointLifecycleTest.java
@@ -16,7 +16,12 @@
  */
 package org.apache.camel.component.a2a;
 
+import org.apache.camel.Expression;
+import org.apache.camel.component.a2a.model.AgentCard;
+import org.apache.camel.component.a2a.model.SupportedInterface;
+import org.apache.camel.component.a2a.util.A2AJsonMapper;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -60,6 +65,30 @@ class A2AEndpointLifecycleTest {
         }
     }
 
+    @Test
+    void simpleUsesConsumerBindingWhenEndpointAlsoHasAProducer() throws 
Exception {
+        try (DefaultCamelContext context = new DefaultCamelContext()) {
+            context.start();
+            A2AEndpoint endpoint = endpoint(context, "stock");
+            endpoint.getConfiguration().setProtocolBinding("JSONRPC");
+            
endpoint.getConfiguration().setAgentCard(AgentCard.builder().setUrl("https://example.com/stock";).build());
+            endpoint.createProducer();
+            endpoint.createConsumer(exchange -> {
+            });
+            context.addEndpoint(endpoint.getEndpointUri(), endpoint);
+
+            assertThat(endpoint.getResolvedCard().getSupportedInterfaces())
+                    
.extracting(SupportedInterface::getProtocolBinding).containsExactly("HTTP+JSON");
+            Expression expression = 
context.resolveLanguage("simple").createExpression("${a2a:card}");
+            String local = expression.evaluate(endpoint.createExchange(), 
String.class);
+            String remote = expression.evaluate(new DefaultExchange(context), 
String.class);
+            assertThat(A2AJsonMapper.instance().readValue(local, 
AgentCard.class).getSupportedInterfaces())
+                    
.extracting(SupportedInterface::getProtocolBinding).containsExactly("JSONRPC");
+            assertThat(A2AJsonMapper.instance().readValue(remote, 
AgentCard.class).getSupportedInterfaces())
+                    
.extracting(SupportedInterface::getProtocolBinding).containsExactly("HTTP+JSON");
+        }
+    }
+
     private static A2AEndpoint endpoint(DefaultCamelContext context, String 
agentCardSource) {
         A2AComponent component = new A2AComponent();
         component.setCamelContext(context);
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
index 68ddb9b17fdb..4f7761bb61fc 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
@@ -16,8 +16,14 @@ See the xref:camel-upgrade-recipes-tool.adoc[documentation] 
page for details.
 === camel-a2a - generated agent cards advertise the consumer interface
 
 Generated consumer agent cards now publish a `supportedInterfaces` entry for 
the configured protocol binding.
-A card containing only a legacy `url` now advertises that URL with the 
consumer's binding. A consumer behind
-a reverse proxy can declare `supportedInterfaces` in its card to publish the 
external URL.
+A card containing only a legacy `url` now advertises that URL with the 
consumer's binding. Otherwise, when no
+interface is declared, the advertised URL comes from the HTTP transport. 
Clients that previously fell back to the
+card's source URL, including Camel producers using discovery without 
configured credentials or a host override,
+now follow the advertised interface.
+
+If a proxy rewrites the host or mount path, or terminates TLS, check the URL 
in the served card. If it differs
+from the address clients must use, configure `supportedInterfaces` in the 
consumer's card with the public URL,
+binding, and protocol version before upgrading. The same applies if the 
transport advertises a bind address.
 
 === camel-core - intercept no longer intercepts the steps of onCompletion and 
of other intercepts
 

Reply via email to