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

   ## Summary
   
   Fixes https://issues.apache.org/jira/browse/CAMEL-25323.
   
   The DataWeave auto-conversion pipeline had two silent-failure modes that 
caused hard-to-debug production issues:
   
   1. **Parser silently skipped unexpected tokens** — `expect()` returned the 
current token and advanced past it even when it didn't match, producing 
structurally garbled ASTs (missing closing braces, swapped operators) that 
either failed at runtime with a cryptic DataSonnet error or, worse, silently 
produced wrong results.
   
   2. **Language silently ignored unconvertible constructs** — When 
`getTodoCount() > 0` (e.g. a `match` expression), `DatasonnetLanguage` logged a 
warn and continued, producing a DataSonnet script with `/* TODO */` holes that 
evaluated to `null` at runtime.
   
   ## Changes
   
   ### `camel-dataweave`
   
   - **`DataWeaveConversionException`** (new): dedicated unchecked exception 
for parse and conversion failures. Carries a `line:col: expected X but found Y` 
message so the caller knows exactly where parsing broke.
   
   - **`DataWeaveParser.expect()`**: now throws `DataWeaveConversionException` 
instead of silently skipping the unexpected token.
   
   - **`DataWeaveParser.parsePrimary()` fallback**: now throws 
`DataWeaveConversionException` instead of emitting a silent `Unsupported` node.
   
   - **`DataWeaveParserTest`**: `shouldNotThrowOnUnbalancedInput()` → 
`shouldThrowOnUnbalancedInput()` asserting the new behaviour.
   
   ### `camel-datasonnet`
   
   - **`DatasonnetLanguage.convertDataWeave()`**: throws 
`IllegalArgumentException` when `getTodoCount() > 0`, naming the count and 
including the broken output in the message. The silent `LOG.warn` path is 
removed.
   
   - **`DataWeaveExecutedCorpusTest`** (new): 12 end-to-end tests that load 
real `.dwl` resources from `src/test/resources/corpus/`, send a JSON body 
through a live Camel DataSonnet route, and assert the output JSON:
     - field access + arithmetic
     - string concatenation
     - if/else with three score thresholds (A/B/C)
     - `map` transform
     - `filter`
     - `reduce`
     - builtin functions (`upper`, `lower`, `sizeOf`)
     - type coercion (`as Number`, `as String`)
     - negative: `match` expression → `IllegalArgumentException` at expression 
creation
     - negative: missing `}` → `DataWeaveConversionException` propagated
   
   ## Test results
   
   ```
   [INFO] Tests run: 89, Failures: 0, Errors: 0, Skipped: 0  (camel-dataweave)
   [INFO] Tests run: 79, Failures: 0, Errors: 0, Skipped: 0  (camel-datasonnet)
   ```
   
   _Authored with Claude Sonnet 4.6 on behalf of gnodet_


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