[
https://issues.apache.org/jira/browse/CAMEL-25323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18124848#comment-18124848
]
Guillaume Nodet commented on CAMEL-25323:
-----------------------------------------
This issue is being investigated by a coding agent (on behalf of gnodet).
Initial code review confirmed:
- The DataWeave parser's expect() method silently skips missing tokens instead
of reporting errors, producing garbled ASTs without any diagnostic.
- DatasonnetLanguage.convertDataWeave() only logs a WARN when conversion fails,
with no option to fail fast and no location info identifying which construct
failed.
- Existing tests in DataWeaveConverterTest (~55 tests) only check text output,
never execute the generated DataSonnet through an actual Camel route.
- The one end-to-end test (DataWeaveAutoDetectTest) only covers two trivial
cases.
A fix will address strict parser error reporting, fail-fast behavior on
unconverted constructs, and add an executed test corpus.
_Note: This comment was generated by an AI coding agent and requires manual
verification._
> camel-dataweave - unconverted DataWeave fails silently or points at the
> generated DataSonnet; add an executed test corpus
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25323
> URL: https://issues.apache.org/jira/browse/CAMEL-25323
> Project: Camel
> Issue Type: Bug
> Reporter: Claus Ibsen
> Assignee: Guillaume Nodet
> Priority: Major
>
> DataWeave scripts ({{.dwl}} or inline {{%dw}}) are translated to DataSonnet
> when the route starts (CAMEL-23530). When the translator cannot handle
> something, the user does not find out properly:
> * The parser skips tokens it does not understand and skips missing brackets
> without an error ({{DataWeaveParser.expect()}} and the {{parsePrimary}}
> fallback). Only {{match}} and "unexpected token" are counted as "could not
> convert".
> * When something is not converted, the route still starts.
> {{DatasonnetLanguage.convertDataWeave}} only logs a WARN and that part
> becomes {{null}}. Example: {{payload.name match \{ case "bob" -> 1 else -> 0
> \}}} silently returns {{\{"k":null\}}}.
> * When the translated script does fail, the error refers to a line and column
> in the generated DataSonnet, which the user never wrote, e.g. {{Problem
> parsing: Expected ")":6:21, found "$) null, b"}} for {{payload.items filter
> ($.qty > 1)}}.
> * The 55 tests in {{DataWeaveConverterTest}} only check that the output
> contains certain text ({{assertTrue(result.contains(...))}}). None of them
> run the generated DataSonnet, which is how the bugs in the follow-up issue
> got through.
> Proposal:
> # By default, fail at route start when any part could not be converted. The
> message should name the DataWeave line, the construct, and a hint (e.g.
> "match is not supported, rewrite as if/else"). Keep the lenient behaviour
> only as an explicit option.
> # Make the parser strict: a missing token or an unknown token is an error
> with the DataWeave line and column, not something to skip.
> # Where possible, also report DataSonnet runtime errors with the original
> DataWeave location.
> # Add a test set that runs end to end: one case per file with the {{.dwl}}
> script, an input message and the expected output, run through
> camel-datasonnet. Use it to cover the follow-up fixes.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)