davsclaus commented on code in PR #27552:
URL: https://github.com/apache/camel/pull/27552#discussion_r4221880079


##########
components/camel-dataweave/src/main/java/org/apache/camel/component/dataweave/DataWeaveParser.java:
##########
@@ -745,7 +751,12 @@ private void advance() {
     private void expect(TokenType type) {
         if (check(type)) {
             advance();
+        } else {
+            Token cur = current();
+            throw new DataWeaveConversionException(

Review Comment:
   Throwing here also reaches the `camel transform dataweave` CLI for valid 
DataWeave the parser does not model yet. Two cases traced through the code:
   
   - conditional object elements `{ (a: 1) if cond }`: the dynamic-key branch 
in `parseObjectLiteral` parses `a`, then `expect(RPAREN)` finds `COLON`;
   - XML attribute syntax `root @(id: 1): {...}`: the lexer drops `@`, so 
`expect(COLON)` finds `(`.
   
   `TransformDataWeave.convertFiles()` has no try/catch around 
`converter.convert(...)`, so in directory mode the first such file aborts every 
file after it. Before this PR both cases produced output with TODOs.
   
   Suggestion: in the CLI, catch `DataWeaveConversionException` per file, print 
`file: message`, count it as a failure, continue, and exit non-zero at the end. 
A CLI test with a conditional-element file would lock that in, and the CLI 
behaviour change deserves a line in the upgrade guide too.



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