Claus Ibsen created CAMEL-25470:
-----------------------------------
Summary: camel-dataweave - $ shorthand with .@attr, .*field or ?
is mis-converted without a TODO
Key: CAMEL-25470
URL: https://issues.apache.org/jira/browse/CAMEL-25470
Project: Camel
Issue Type: Bug
Reporter: Claus Ibsen
Fix For: 4.23.0
The DataWeave to DataSonnet converter mis-parses the $ lambda shorthand when it
is followed by an XML attribute selector (.@attr), a multi-value selector
(.*field) or an existence check (?). parseDollarShorthand() consumes the dot
but only collects identifiers, so the rest of the expression is parsed wrongly
and no TODO is counted, which means DatasonnetLanguage's fail-fast check
(CAMEL-25323) does not catch it.
Examples on main:
||DataWeave||Emitted today||
|payload.items map $.@id|std.map(function(x) x., body.items) - invalid Jsonnet|
|payload.items map $.*Item|std.map(function(x) x., body.items) * Item|
|payload.items reduce ($$ + $.*price)|acc + item * price - silently wrong|
|payload.items reduce ($$ + $.@qty)|parse error: expected RPAREN but found AT|
|payload.items filter $.price?|? binds to the whole filter expression|
In addition, a reduce shorthand body ($$ / $) that uses if/else or default
(e.g. payload.items reduce ($$ + $.price default 0)) is not supported and is
emitted as a TODO.
The explicit lambda form (item, acc = 0) -> acc + item.@qty is converted
correctly.
Follow-up to CAMEL-25324 and CAMEL-25323.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)