oscerd commented on issue #2872:
URL: 
https://github.com/apache/camel-kamelets/issues/2872#issuecomment-5830400149

   Ran the direct producer test. **My last two comments were wrong: Floci is 
fine, `aws-ddb-sink` is fine, and the delete never happened because the test's 
JSON body never reached Camel as JSON.** PR: #3063.
   
   ## What the integration was actually doing
   
   The Citrus log only shows the verification retrying to exhaustion, which is 
what led me to blame the delete. The integration's own dump 
(`citrus.camel.cli.dump.integration.output=true`, at 
`.citrus-jbang/i-aws-ddb-sink-route-output.txt`) shows the route dying one step 
*before* DynamoDB:
   
   ```
   [JVM System Property]  aws.ddb.json.data = {id: 2171}
   ...
   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
   ```
   
   `{id: 2171}` — the quotes are gone. Citrus hands each system property to 
Camel JBang as `-Dkey="value"`; `JBangSupport` formats it literally as 
`-D%s="%s"`. A value containing bare double quotes collides with that wrapper 
and arrives unquoted.
   
   This test was the only one under `aws/ddb/` that wrote its body with bare 
quotes:
   
   | test | body as written | reaches Camel as |
   |---|---|---|
   | `put-item` | `{ \"id\": ..., \"year\": ..., \"title\": \"...\" }` | valid 
JSON |
   | `update-item` | `{ \"key\": {\"id\": ...}, \"item\": {...} }` | valid JSON 
|
   | `delete-item` | `{"id": ...}` | `{id: ...}` — **not JSON** |
   
   So no DynamoDB request was issued at all, the seeded item survived, and the 
assertion expected exactly the untouched item. Green for precisely the wrong 
reason.
   
   I should have read the integration dump before concluding anything about the 
emulator — the shared route filename means all three sink tests overwrite the 
same dump file, so it only survives if the delete test runs last or alone.
   
   ## Retracting the two claims
   
   **"Floci does not implement `DeleteItem`."** It does. Standalone 
`floci/floci:latest`, no Camel involved:
   
   ```
   $ 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, ...}
   ```
   
   **"Something in the producer path drops it."** It does not. The same route 
the test runs, via `camel run` against standalone Floci, 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)}
   ```
   
   Table empty afterwards. Same on Camel 4.22.0 and 4.23.0-SNAPSHOT, and 
against real LocalStack 4.14.0 as well.
   
   One aside worth recording, since it cost me a run: pointing 
`--local-kamelet-dir` at the repository root instead of `kamelets/` silently 
falls back to the catalog bundled with the Camel CLI. On 4.22.0 that catalog 
still carries the `dataTypes.in.default: json` bug from #2941, so the Kamelet 
turns every message into a `PutItem`. That is a stale-catalog artefact, not 
current behaviour.
   
   ## The fix
   
   Both lines, in #3063:
   
   ```diff
   -            {"id": ${aws.ddb.item.id}}
   +            { \"id\": ${aws.ddb.item.id} }
   ```
   ```diff
   -          value: "[[id:AttributeValue(N=${aws.ddb.item.id}), title:..., 
year:...]]"
   +          value: "[]"
   ```
   
   `AwsIT#awsDdb` 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 satisfies on its first attempt now, and the dump 
shows `aws.ddb.json.data = { "id": 7141 }` arriving intact.
   
   That closes the last of this issue's three TODOs: migrated off LocalStack, 
all four tests re-enabled, and the delete-item assertion now correct and 
meaningful.
   
   ---
   _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]

Reply via email to