Claus Ibsen created CAMEL-24702:
-----------------------------------
Summary: camel-yaml-dsl - accept handled: true / continued: true
on onException (boolean shorthand for the predicate)
Key: CAMEL-24702
URL: https://issues.apache.org/jira/browse/CAMEL-24702
Project: Camel
Issue Type: Improvement
Components: camel-yaml-dsl
Reporter: Claus Ibsen
In the YAML DSL the natural way to write a handled exception clause
{code}
- onException:
exception:
- java.lang.Exception
handled: true
steps:
- log: "Error: ${exception.message}"
{code}
is rejected by camel validate yaml ("/0/onException/handled: boolean found,
object expected") and by the runtime ("Error starting Camel: Error constructing
YAML node id: org.apache.camel.model.ExpressionSubElementDefinition"). The only
accepted form is the expression object, handled: {constant: "true"} (or the
nested constant: "true"), because handled and continued are
ExpressionSubElementDefinition (a predicate) in the model. Java DSL has both
handled(boolean) and handled(Predicate); XML has the same expression element.
Both the schema error and the runtime error are hard to act on: neither says
"write handled: constant: true". In the AI authoring benchmark on 2026-09-12 a
local model wrote handled: true, got "boolean found, object expected", then
tried handled: {constant: true}, logException: true, a deadLetterChannel with
handled: true, and gave up after seven refused writes. Humans write handled:
true too.
Suggested improvement, in camel-yaml-dsl:
* accept a boolean scalar for handled and continued (and the other
ExpressionSubElementDefinition predicates on onException, such as retryWhile)
in the deserializer, wrapping it as a constant expression; the same applies to
the schema generated by GenerateYamlSchemaMojo (a oneOf of boolean and the
expression object), so tooling keeps the type information;
* or, if the shorthand is not wanted, make the validator message say what the
expected form is (for example: "handled: expected an expression, for example
handled: {constant: true}").
4.23.0-SNAPSHOT; reproducer above with a throwException route.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)