Claus Ibsen created CAMEL-24826:
-----------------------------------
Summary: camel validate: flag a ternary operator in a Simple
expression, it is not supported and comes out as literal text
Key: CAMEL-24826
URL: https://issues.apache.org/jira/browse/CAMEL-24826
Project: Camel
Issue Type: Improvement
Components: camel-jbang, camel-core
Reporter: Claus Ibsen
Found twice while writing examples for CAMEL-24808 and in the local-model
benchmark.
Simple has no ternary operator, but a model, and a human copying from another
language, writes one:
{code}
setBody:
expression:
simple:
expression: "${body.size()} == 0 ? ${null} : ${body[0]}"
{code}
At runtime this evaluates to the literal text "1 == 0 ? : {sku=CAMEL-MUG,
qty=42}" and is silently used as the body; a nested form inside a function
fails at runtime with "Unknown function". *camel validate yaml* (and the
validate tool of the MCP server) accepts both.
Proposal: the Simple language validator (parse or a dedicated check) reports a
" ? " with a " : " at the top level of an expression as "Simple has no ternary
operator; use a choice, or a jsonpath/groovy expression", with the position.
Same message from the MCP validate tool.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)