Claus Ibsen created CAMEL-24703:
-----------------------------------
Summary: camel-core-languages - simple: error messages should say
what to write (audit against typical mistakes)
Key: CAMEL-24703
URL: https://issues.apache.org/jira/browse/CAMEL-24703
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: Claus Ibsen
Every error message the Simple parser can produce was listed (about 60 throw
sites in core/camel-core-languages) and checked against 50 expressions a local
model typically writes in the AI authoring benchmark (2026-09-12). A model
recovers from a message that says what to write and loops on one that only says
what was wrong. The rendered form (message, "at location N", the expression and
the * marker) is good; the texts should name the fix. The main cases:
|| model writes || today || proposed ||
| body == 'Hello World' | Unexpected token b at location 0 | Unexpected token
'b': text outside ${...} is a literal, functions are written as ${body},
${header.name}. Did you mean ${body} == 'Hello World'? |
| ${body == 'x'} | Valid syntax: ${body.OGNL} was: body == 'x' | Operators go
outside the function: ${body} == 'x' |
| ${body} == x | Binary operator == does not support token null | Binary
operator == needs a value on the right hand side: a quoted literal 'x', a
number, true, false, null, or a function ${...}; was: x (never print "token
null") |
| ${body} = 'x' | Unexpected token = | Unknown operator '=': did you mean '=='?
Operators: ==, =~, !=, <, <=, >, >=, contains, !contains, ~~, regex, in, !in,
is, !is, range, !range, startsWith, endsWith |
| ${body} == 'x' and ${header.y} == 1 | Unexpected token a | Unknown operator
'and': use && for and, \|\| for or |
| ${body} == 'x' \|\| | Logical operator \|\| does not support token null |
Logical operator \|\| needs a predicate on the right hand side |
| ${body} == 'it''s' | expected symbol whiteSpace but was singleQuote | A
literal that contains a single quote must use double quotes: "it's" |
| ${header.foo | expected symbol functionEnd but was eol | Missing } to close
${header.foo |
| ${padding(3)} | Unknown function: padding(3) | Unknown function 'padding':
did you mean pad(3)? (closest known name; the functions are listed on the
simple language functions page) |
| ${upper(${body})} | Unknown function: upper(${body}) | as above, plus: a
nested ${...} inside a function argument is not supported |
| ${property.foo} | Unknown function: property.foo | Unknown function
'property': it is exchangeProperty.foo since Camel 3 (alias table for the Camel
2 names) |
| ${ body }, ${Body} | Unknown function: body / Body | remove the spaces /
functions are lower camel case: ${body} |
| ${jsonpath($.name)} without the jar | No language could be found for:
jsonpath | add camel-jsonpath to the classpath
(org.apache.camel:camel-jsonpath) |
| ${body.length() > 3} | runtime: Failed to invoke method: length() > 3 on null
due to: Method should end with parenthesis | Operators go outside the function:
${body.length()} > 3 |
| ${body.lenght()} | runtime: Failed to invoke method: lenght() on null due to:
MethodNotFoundException ... on bean: hello | drop the wrong "on null"; Method
lenght() not found on java.lang.String; did you mean length()? |
| ${body.toUpperCase} | runtime: Failed to invoke method: toUpperCase on null
due to: CamelExecutionException: Exception occurred during execution | No
method or property toUpperCase on java.lang.String; a method call needs ():
${body.toUpperCase()} |
Accepted silently but not what was meant, where the eval tool and validator can
add a note: ${header.count} + 1 (Simple has no arithmetic, the + 1 is text),
${body} ? 'a' : 'b' (no ? : operator; the elvis operator is ?: and a
conditional is iif(...)).
Implementation notes: the parse time messages come from SimpleParserException
in BaseSimpleParser, SimplePredicateParser, SimpleExpressionParser, the ast
nodes and the function factories; "token null" has one origin per parser (does
not support token / has no left or right hand side token); the known function
names for suggestions are the BUILT_INS and EXPRESSION_ENTRIES in
SimpleFunctionDispatcher plus the fixed set; the catalog validator, camel
validate yaml, the TUI and the MCP tools all print these messages, so every
consumer benefits. The full audit with the probe program (SimpleProbe.java, 50
cases) is kept with the benchmark material.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)