From abdef7cbd2fe4c1607ceef5ddcd8337588956cd9 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Fri, 28 Aug 2026 06:55:49 +0200 Subject: [PATCH] Fix #2941: make aws-ddb-sink honour its own operation property The Kamelet declared an inbound data type default: dataTypes: in: default: json which makes Camel apply the aws2-ddb:application-json transformation at the kamelet:source boundary, before any template step runs. So by the time "setProperty operation" executed, the transformer had already resolved the operation from the body alone, defaulted to PutItem and stamped CamelAwsDdbOperation. That header then beat the endpoint's operation={{operation}} parameter in Ddb2Producer, leaving the Kamelet's operation property with no effect. The in-template transformDataType step was a no-op as a result: the transformer returns early once CamelAwsDdbItem or CamelAwsDdbKey is set. Dropping only the "default:" key stops the transformation happening at the boundary and lets the existing transformDataType step apply it after the operation is set. All of the declared input-type documentation -- schema, header docs, description -- is preserved. Probed each operation with `camel run`, replacing the terminal aws2-ddb endpoint with a log so the resolved headers are visible: PutItem CamelAwsDdbItem + ALL_OLD DeleteItem CamelAwsDdbKey + ALL_OLD UpdateItem CamelAwsDdbKey + CamelAwsDdbUpdateValues + ALL_NEW Before the change UpdateItem produced the PutItem shape. The itest route carried a workaround that set the operation exchange property in the calling route; it is removed here, so the test now exercises the Kamelet's own property. AwsIT passes end to end against DynamoDB: 15 tests, 0 failures, all four ddb cases green. Co-Authored-By: Claude Opus 5 (1M context) --- kamelets/aws-ddb-sink.kamelet.yaml | 7 ++++++- .../src/test/resources/aws/ddb/aws-ddb-sink-route.yaml | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kamelets/aws-ddb-sink.kamelet.yaml b/kamelets/aws-ddb-sink.kamelet.yaml index e978ccee1..5e1e611c3 100644 --- a/kamelets/aws-ddb-sink.kamelet.yaml +++ b/kamelets/aws-ddb-sink.kamelet.yaml @@ -103,8 +103,13 @@ spec: type: boolean default: false dataTypes: + # No 'default:' here on purpose. Declaring a default input type makes Camel + # apply the aws2-ddb:application-json transformation at the kamelet:source + # boundary, before any step below runs -- so the operation set by this + # template was never visible to it and every message was transformed as + # PutItem. The transformDataType step below applies the same type after the + # operation is set. See #2941. in: - default: json types: json: format: "aws2-ddb:application-json" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml index 1b8cbc6dd..06ef96047 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml @@ -24,9 +24,6 @@ steps: - setBody: constant: "{{aws.ddb.json.data}}" - - setProperty: - name: operation - constant: "{{aws.ddb.operation}}" - log: "${body}" - to: uri: "kamelet:aws-ddb-sink"