davsclaus opened a new issue, #3088:
URL: https://github.com/apache/camel-kamelets/issues/3088

   `extract-field-action` returns the extracted field re-marshalled as JSON by 
default (`trimField: false`). For a string field that means the body is the 
value with JSON quotes, as an `InputStreamCache`. A comparison on the value 
then fails.
   
   Reproduce with `camel run` (camel-kamelets 4.22.1, Camel 4.23.0-SNAPSHOT):
   
   ```yaml
   - route:
       from:
         uri: kamelet:timer-source
         parameters:
           repeatCount: 1
           message: '{"orderId":"ORD-1","status":"paid"}'
           contentType: application/json
         steps:
           - to:
               uri: kamelet:extract-field-action
               parameters:
                 field: orderId
           - log:
               message: "[${body}] type ${bodyType} content-type 
${header.Content-Type}"
   ```
   
   | | body | body type | Content-Type | `${body} == 'ORD-1'` |
   |---|---|---|---|---|
   | default (`trimField: false`) | `"ORD-1"` | `InputStreamCache` | 
`application/json` | no |
   | `trimField: true` | `ORD-1` | `String` | `application/json` | yes |
   
   Two points to discuss:
   
   1. **The default.** Most users of "extract a field" expect the value, not 
the value as a JSON document. The property description, "If enabled we return 
the Raw extracted field", doesn't say that the default wraps a string in 
quotes. Either the default could be `true`, or the description and docs could 
say what the default output looks like. Changing the default changes behaviour, 
so it may be better for a major version or with an upgrade note.
   2. **`trimField: true` keeps `Content-Type: application/json`** on a body 
that is no longer JSON (`ORD-1`). A later step that branches on the content 
type, such as another action Kamelet that unmarshals when the header is 
`application/json`, will then try to parse plain text.
   
   Context: this showed up in a local-model benchmark of Camel routes built 
with Kamelets. A model chaining `extract-field-action` with a filter on the 
value got the quoted form and didn't recognise why the compare failed. A human 
hits the same thing.
   


-- 
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