Claus Ibsen created CAMEL-27640:
-----------------------------------

             Summary: camel-a2a: dead returnImmediately header/historyLength, 
streaming/paging gaps, labels
                 Key: CAMEL-27640
                 URL: https://issues.apache.org/jira/browse/CAMEL-27640
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of camel-a2a for CAMEL-23832 (PR 
https://github.com/apache/camel/pull/30978).
These are separate problems of the component; the descriptions PR only 
documents the current behavior.

h4. 1. The CamelA2AReturnImmediately header has no effect
{{A2AConsumer.resolveReturnImmediately()}} reads the header from the exchange 
of the HTTP request. {{handleSendMessage()}} and {{handleJsonRpcDispatch()}} 
call {{filterInboundHeaders()}} first, and it removes every header whose name 
starts with {{camel}}, so the header is never there. The producer does not send 
it either. The docs ({{a2a-component.adoc}}, {{a2a-consumer.adoc}}) describe it 
as a per-request override that takes precedence over the endpoint option.
Proposed change: remove the header (and its docs), or read it where a route can 
set it.

h4. 2. The historyLength endpoint option does nothing
{{A2AConfiguration.validate()}} checks that {{historyLength}} is not negative, 
but no code reads {{getHistoryLength()}}. The producer takes the history length 
from the {{CamelA2AHistoryLength}} header (TASK_GET, TASK_SUBSCRIBE) and from 
{{CamelA2AListHistoryLength}} (TASK_LIST).
Proposed change: use the option as the default when the header is not set, or 
deprecate it.

h4. 3. asyncTimeout=0 breaks producer streaming operations
{{A2AConfiguration.validate()}} accepts {{asyncTimeout=0}}, and the consumer 
treats 0 as no timeout ({{A2AConsumer.submitRun()}}). 
{{A2AProducer.buildHttpRequest()}} passes the value to 
{{HttpRequest.Builder.timeout()}} for MESSAGE_STREAM and TASK_SUBSCRIBE. That 
method throws {{IllegalArgumentException}} for a zero duration, so every 
streaming request of the producer fails.
Proposed change: on the producer, set no request timeout when the value is 0.

h4. 4. With HTTP+JSON, PUSH_CONFIG_GET and PUSH_CONFIG_DELETE ignore 
CamelA2APushConfigId
{{RestProtocol.resolvePath()}} builds the path from the {{CamelA2ATaskId}} 
header only, and expects {{taskId:configId}} in it. With a plain task id, the 
request goes to {{/tasks/TASK_ID/pushNotificationConfigs}}, which is the list 
path. The {{CamelA2APushConfigId}} header that {{PushConfigGetOperation}} and 
{{PushConfigDeleteOperation}} read is not used for the REST path. 
{{a2a-producer.adoc}} works around it by recommending JSON-RPC.
Proposed change: pass the push config id to {{resolvePath()}} for these two 
operations.

h4. 5. The producer drops nextPageToken of TASK_LIST
{{TaskListOperation.parseResponse()}} sets the body to 
{{ListTasksResponse.tasks()}} and sets no header for {{nextPageToken}}, 
{{pageSize}} or {{totalSize}}. A route cannot page through the tasks, except 
with {{dataFormat=RAW}}.
Proposed change: set the next page token as a header, for example 
{{CamelA2AListNextPageToken}}.

h4. 6. returnImmediately=true rejects SendStreamingMessage only with the REST 
binding
{{A2AConsumer.handleMessageStream()}} (HTTP+JSON) rejects a streaming request 
for which {{resolveReturnImmediately()}} is true, with HTTP 400. 
{{handleJsonRpcStream()}} (JSONRPC) does not check it and streams. With 
{{returnImmediately=true}} on the endpoint, every REST streaming request is 
rejected unless the request sets {{returnImmediately}} to false.
Proposed change: treat both bindings the same, and do not apply the endpoint 
default to streaming requests.

h4. 7. An async task answered with a message stays TASK_STATE_WORKING
With {{returnImmediately}}, {{A2AConsumer.submitAsyncTask()}} stores the result 
only when {{buildResponse()}} gives a task response. When the route sets 
{{CamelA2AReplyType=message}}, the task that was stored as SUBMITTED and then 
WORKING is not updated when the route ends. A client that polls with GetTask 
sees TASK_STATE_WORKING.
Proposed change: complete the task with the reply message, or reject 
{{CamelA2AReplyType=message}} for async requests.

h4. 8. Wrong labels of headers
{{CamelA2AHistoryLength}}, {{CamelA2AReturnImmediately}}, 
{{CamelA2APushConfigId}} and the seven {{CamelA2AList*}} headers are labelled 
{{common}} in {{A2AConstants}}. Only the producer reads them; the consumer 
reads the query parameters and the request body instead.
Proposed change: label them {{producer}}.

h4. 9. Wrong or missing labels of options
In {{A2AConfiguration}}:
* {{connectTimeout}} is labelled {{producer,advanced}}, but the endpoint also 
uses it for the push notifications of the consumer and for the download of the 
agent card.
* {{host}} and {{port}} are only used by the producer 
({{A2AProducer.resolveBaseUrl()}}) and have no producer label.
* {{returnImmediately}}, {{validateAuth}}, {{completedTaskTtl}}, 
{{pushRetryAttempts}} and {{pushRetryBackoffMs}} are only used by the consumer 
and have no consumer label.
Proposed change: fix the labels.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to