Claus Ibsen created CAMEL-26030:
-----------------------------------

             Summary: camel-aws2-ddb - wrong header types in the catalog, 
CamelAwsDdbNextToken missing, and result headers read by the next step
                 Key: CAMEL-26030
                 URL: https://issues.apache.org/jira/browse/CAMEL-26030
             Project: Camel
          Issue Type: Bug
          Components: camel-aws2
    Affects Versions: 4.18.0, 4.22.0, 4.23.0
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of aws2-ddb and aws2-ddbstream 
(CAMEL-24961). The body is fine: every operation keeps it and puts its result 
in headers. The headers are where these are.

h4. 1. The catalog gives wrong types for result headers

The {{javaType}} of these headers in {{Ddb2Constants}} (main 07d2e7a987bc) is 
not what the producer sets:
* {{CamelAwsDdbTableStatus}}: String, but the {{TableStatus}} enum of the AWS 
SDK (line 131);
* {{CamelAwsDdbCreationDate}}: Date, but a {{java.time.Instant}} (line 50);
* {{CamelAwsDdbConsumedCapacity}}: Double, but a {{ConsumedCapacity}} object, 
which is always null, as Query and Scan never ask for it with 
ReturnConsumedCapacity (line 44);
* {{CamelAwsDdbLastEvaluatedKey}}: Key, but a {{Map<String, AttributeValue>}} 
(line 89);
* {{CamelAwsDdbBatchResponse}}: {{Map<String, BatchResponse>}}, but a 
{{Map<String, List<Map<String, AttributeValue>>>}} (line 36);
* {{CamelAwsDdbFilterExpressionAttributeValues}}, an input: {{Map<String, 
String>}}, but read as a {{Map<String, AttributeValue>}} (line 205; 
{{AbstractDdbCommand}}, line 119).

Checked on 4.24.0-SNAPSHOT with {{camel run}} against the AWS emulator of 
{{camel infra run aws}}: DescribeTable gave a TableStatus and an Instant, and 
Scan an empty ConsumedCapacity header.

*Proposed change*: correct the javaType of these headers; ask for the consumed 
capacity, or drop the header.

h4. 2. CamelAwsDdbNextToken is not in the catalog

ExecuteStatement reads the {{CamelAwsDdbNextToken}} header and sets it to the 
token of the next page ({{ExecuteStatementCommand}}, lines 47 and 56), but the 
constant has no {{@Metadata}} ({{Ddb2Constants}}, line 74), so the catalog and 
the docs do not list it. Checked on 4.24.0-SNAPSHOT with {{camel run}} against 
the AWS emulator of {{camel infra run aws}}: ExecuteStatement set it.

*Proposed change*: add the {{@Metadata}}.

h4. 3. The next aws2-ddb step reads headers that a step set as its result

Some result headers are also inputs, so a second aws2-ddb step in a route uses 
what the first one gave:
* DescribeTable and DeleteTable set {{CamelAwsDdbTableName}} 
({{DescribeTableCommand}}, line 37; {{DeleteTableCommand}}, line 42), which the 
next step takes as its table ({{AbstractDdbCommand}}, line 47);
* DescribeTable sets {{CamelAwsDdbReadCapacity}} and 
{{CamelAwsDdbWriteCapacity}} (lines 42-43), which a following UpdateTable reads 
before its options ({{UpdateTableCommand}}, lines 39-47);
* ExecuteStatement sets {{CamelAwsDdbNextToken}}, which the next 
ExecuteStatement sends again, so it reads the next page of another query.

*Proposed change*: remove the input headers a command sets before setting the 
result, or name the result headers apart from the inputs.

h4. Also read in the code, not run

* UpdateTable drops the response and sets no header ({{UpdateTableCommand}}, 
lines 33-36).
* aws2-ddbstream: the section "Sequence Numbers" of the docs describes an 
option that CAMEL-16594 removed; the docs say a DynamoDbStreamsClient must be 
in the registry, but the access key and the credentials providers work too; the 
catalog lists no headers, as {{@UriEndpoint}} of {{Ddb2StreamEndpoint}} has no 
headersClass.
* The docs write the uri as {{aws2-ddb://domainName}}; the path is the table 
name.
* {{AWS2BatchGetItemsRuleIT}}: the putItem helper sends BatchGetItems, so 
nothing is put, and the test only checks that the headers are not null.

_Claude Code on behalf of davsclaus_



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

Reply via email to