Claus Ibsen created CAMEL-24692:
-----------------------------------

             Summary: camel-catalog: validateLanguagePredicate/Expression for 
simple rejects property placeholders used as operands
                 Key: CAMEL-24692
                 URL: https://issues.apache.org/jira/browse/CAMEL-24692
             Project: Camel
          Issue Type: Bug
          Components: camel-catalog
            Reporter: Claus Ibsen


h3. Problem
{{AbstractCamelCatalog.doValidateSimple}} substitutes {{{{X}}}} with {{~^X^~}} 
before handing the text to the Simple parser, so placeholders can be parsed 
without a running CamelContext. That works when the placeholder sits inside 
{{${...}}}, but when a placeholder is a bare operand of a binary operator, or 
the whole expression, the parser sees the {{~^}} token and fails. The runtime 
resolves property placeholders before parsing Simple, so the same expressions 
load and run in a route. The validator therefore rejects valid routes.

h3. Reproducer
camel-catalog 4.23.0-SNAPSHOT, {{CamelCatalog.validateLanguagePredicate(null, 
"simple", text)}}:
{code}
ERROR ${body} >= {{hot.threshold}}          -> Binary operator >= does not 
support token ^ at location 12
OK    ${body} >= 30
OK    ${body} >= ${properties:hot.threshold}
ERROR ${header.level} == {{level}}          -> Binary operator == does not 
support token ^ at location 20
ERROR {{hot.threshold}}                     -> Unexpected token ~ at location 0
{code}
A YAML route with {{when: simple: "${body} >= {{hot.threshold}}"}} and 
{{hot.threshold=30}} in application.properties starts with {{camel run}} and 
routes correctly.

h3. Impact
The Camel TUI save-time validation ({{SourceEditAssist}}) and the 
{{tui_write_file}} / {{tui_validate_source}} MCP tools call this method and 
refuse to write a correct file. An AI assistant editing a route was blocked 
four times on a correct edit.

h3. Code
{{core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java}},
 {{doValidateSimple}}; the {{replaceAll}} to {{~^$1^~}} dates from CAMEL-10959 
(2017). The same substitution exists in {{doValidateGroovy}}.

h3. Suggested fix
Substitute placeholders with a token the Simple parser accepts as a literal 
operand (a quoted dummy such as {{'placeholder'}}, or a numeric literal when 
the operator is numeric), or drop binary-operator operands that are pure 
placeholders before parsing, and map error positions back.

Found 2026-09-11 while benchmarking AI-assisted editing in the Camel TUI.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to