oscerd opened a new pull request, #3063:
URL: https://github.com/apache/camel-kamelets/pull/3063
Fixes #2872.
`aws-ddb-sink-delete-item-test` has been passing without ever performing a
`DeleteItem`. This makes it verify the delete.
## What was actually wrong
Not the Kamelet, and not the emulator. The test's JSON body never reached
Camel as JSON.
Citrus hands each system property to Camel JBang as `-Dkey="value"` —
`JBangSupport` formats it exactly that way:
```
-D%s="%s"
```
A value that already contains bare double quotes collides with that wrapper
and arrives unquoted. This test was the only one under `aws/ddb/` written with
bare quotes; `put-item` and `update-item` both escape them as `\"`. So Camel
received:
```
[JVM System Property] aws.ddb.json.data = {id: 2171}
```
and the route died inside the Kamelet, at the step before the DynamoDB call:
```
Failed delivery for (MessageId: ...) at aws-ddb-sink-1[transformDataType1]
aws-ddb-sink.kamelet.yaml:153
org.apache.camel.CamelExecutionException: Failed to get mandatory Json node
from message body
at
Ddb2JsonDataTypeTransformer.getBodyAsJsonNode(Ddb2JsonDataTypeTransformer.java:160)
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected
character ('i' (code 105)):
was expecting double-quote to start field name
```
No DynamoDB request was ever issued, so the seeded item survived untouched —
and the final assertion reused the **pre-delete** expectation:
```yaml
- name: "aws.ddb.items"
value: "[[id:AttributeValue(N=${aws.ddb.item.id}), title:..., year:...]]"
```
The test was green *because* the delete was broken, and would have turned
red the day it started working.
## The change
```diff
- name: "aws.ddb.json.data"
value: >-
- {"id": ${aws.ddb.item.id}}
+ { \"id\": ${aws.ddb.item.id} }
```
```diff
# Verify Kamelet sink
- createVariables:
variables:
- name: "aws.ddb.items"
- value: "[[id:AttributeValue(N=${aws.ddb.item.id}),
title:AttributeValue(S=${aws.ddb.item.title}),
year:AttributeValue(N=${aws.ddb.item.year})]]"
+ value: "[]"
```
Escape the quotes the way the sibling tests do, and assert the table is
empty afterwards.
## Clearing two earlier suspicions
Both were recorded on #2872 and both are wrong; this PR corrects them.
**Floci implements `DeleteItem`.** Direct against a standalone
`floci/floci:latest`, with no Camel in the path:
```
$ aws dynamodb delete-item --table-name movies --key '{"id":{"N":"1234"}}'
--return-values ALL_OLD
{"Attributes": {"id": {"N": "1234"}, "year": {"N": "1985"}, "title": {"S":
"Back to the future"}}}
$ aws dynamodb scan --table-name movies
{"Items": [], "Count": 0, ...}
```
**`aws-ddb-sink` performs a real `DeleteItem`.** The same route the test
runs, driven by `camel run` against a standalone Floci on Camel
4.23.0-SNAPSHOT, with the working-tree `kamelets/`:
```
SENDING {"id": 1234}
AFTER op=DeleteItem key={id=AttributeValue(N=1234)}
attrs={id=AttributeValue(N=1234), year=AttributeValue(N=1985),
title=AttributeValue(S=Back to the future)}
```
and the table is empty afterwards. Same result against real LocalStack
4.14.0, and on Camel 4.22.0.
## Verification
`AwsIT#awsDdb` against Floci, with the fix:
```
✔ TEST SUCCESS: aws-ddb-source-test
✔ TEST SUCCESS: aws-ddb-sink-put-item-test
✔ TEST SUCCESS: aws-ddb-sink-delete-item-test
✔ TEST SUCCESS: aws-ddb-sink-update-item-test
EXIT=0
```
The delete verification now satisfies on its first attempt rather than
retrying to exhaustion, and the integration dump shows the body arriving intact:
```
[JVM System Property] aws.ddb.json.data = { "id": 7141 }
```
`mvn clean install -DskipTests` from the repository root is clean with no
regenerated artifacts.
## Note for reviewers
The `-Dkey="value"` wrapping is a Citrus/JBang behaviour, not something this
repo controls, and the `\"` convention is already established across the other
payload-carrying tests. Worth knowing when writing a new one: a JSON body with
bare quotes will silently arrive mangled rather than fail loudly.
Unrelated to this fix, `aws-ddb-sink-update-item.citrus.it.yaml` still uses
the older `camel: jbang:` action while the other three use `camel: cli:`. Left
alone here.
---
_Claude Code on behalf of Andrea Cosentino_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]