davsclaus opened a new pull request, #30328:
URL: https://github.com/apache/camel/pull/30328

   [CAMEL-27154](https://issues.apache.org/jira/browse/CAMEL-27154)
   
   ## Problem
   
   The YAML DSL validator follows the body through the steps of a route and 
reports a field read on a body that is not parsed yet (CAMEL-24844), such as 
`${body.qty}` or a Groovy `body.lines` on text. Where the catalog does not know 
the body, what a running app saw at the endpoint fills in (CAMEL-25750).
   
   In the local-model benchmark (connect-service-jms-request-reply step 3, r32 
to r35), the stock service gets the order as a `byte[]` from JMS: the route 
before sends the file it read, and JMS sends a file as a `BytesMessage`. In 8 
of 21 runs, the model wrote a Groovy expression that reads `body.lines`, and 
the route failed with `No such property: lines for class: [B`. The validator 
said nothing, for two reasons:
   
   1. It took bytes for text, so names that text has, such as `lines`, were let 
through. A `byte[]` has none of them.
   2. A `jms`, `sjms` or `amqp` consumer written as `uri: jms` with the 
parameters `destinationType` and `destinationName` was known to the validator 
as `jms:stock`. The YAML DSL builds it as `jms:queue:stock`, and the running 
app names it so (the route-structure console reports the endpoint uri of the 
route input). So what the running app saw at such a consumer was never found.
   
   ## Change
   
   - `RouteGraph.endpointOf` builds `destinationType:destinationName` as the 
path, as the YAML DSL does (`jms:queue:stock`; `jms:stock` when no 
`destinationType` is given, as before).
   - The walk knows a body of bytes: what the running app saw (`byte[]`), or a 
consumer or producer that the catalog says gives only bytes (such as Kafka with 
the `ByteArrayDeserializer`).
   - On bytes, the names of text (`lines`, `text`, `trim`, `blank`, `chars`, 
`bytes`) are field reads, and the message says that the body is still bytes:
   
   ```
   route stock-service: groovy reads fields of the body (body.lines), but the 
body here is still bytes (a byte[]), not parsed data - in the running app, 
from: jms:queue:stock gave a byte[]: unmarshal it first with the data format of 
the payload (json, jacksonXml, csv, ...) to read its fields
   ```
   
   Names that any object or array has, such as `length`, `size` or `empty`, are 
not reported. `JsonSlurper.parseText(body)` is not a field read and is not 
reported (with CAMEL-27150 it parses bytes).
   
   ## Tests
   
   - `TextBodyFlowTest`: a `body.lines` read on the `byte[]` that the running 
app saw at `jms:queue:stock` is reported, for the consumer written with 
`destinationType` and `destinationName`; a `String` there and `body.length` are 
not. The test fails without the change.
   - camel-yaml-dsl-validator: 371 tests run, 0 failures.
   - camel-jbang-core, the `commands.ai` tests with this validator: 1093 run, 0 
failures, 1 skipped.
   - The catalog builds the same uri: `asEndpointUri("jms", {destinationType: 
queue, destinationName: stock})` is `jms:queue:stock`.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDi5iQNgtHrDdz2NpwF
   


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