Claus Ibsen created CAMEL-24700:
-----------------------------------

             Summary: camel-yaml-dsl - circuitBreaker with onFallback before 
steps puts the steps into the fallback (Definition has no children)
                 Key: CAMEL-24700
                 URL: https://issues.apache.org/jira/browse/CAMEL-24700
             Project: Camel
          Issue Type: Bug
          Components: camel-yaml-dsl
            Reporter: Claus Ibsen


In the YAML DSL a circuitBreaker whose onFallback key is written before its 
steps key fails to start:

{code}
- circuitBreaker:
    onFallback:
      steps:
        - log: "fallback"
    steps:
      - log: "inside"
{code}

{noformat}
Failed to create route: cb at: >>> CircuitBreaker[[]] <<< ... because: 
Definition has no children on CircuitBreaker[[]]
{noformat}

With steps before onFallback the same route runs. Key order in a YAML mapping 
should not matter, and camel validate yaml accepts both forms (the JSON schema 
cannot express order).

Cause: CircuitBreakerDefinition.addOutput redirects every output into the 
fallback once onFallback is set (the Java fluent DSL contract, so that 
.onFallback().to(...) works). The generated 
CircuitBreakerDefinitionDeserializer handles the keys in document order: 
"onFallback" calls target.setOnFallback(val), and a later "steps" calls 
setSteps(target, node), which adds each step with addOutput, so the steps end 
up inside the fallback and the circuit breaker itself has no outputs.

doTry (doCatch/doFinally before steps) and choice are not affected: 
TryDefinition.addOutput does not redirect, and choice has no steps key.

Suggested fix: in the deserializer, add the steps with the plain outputs list 
(for example target.getOutputs().add(...) or a setSteps that bypasses the 
fluent redirect), or defer setOnFallback until after the steps are applied. A 
test in camel-yaml-dsl with onFallback first should pass.

Reproducer: 4.23.0-SNAPSHOT, camel run with the YAML above. Found on 2026-09-12 
by a local model in the AI authoring benchmark: the model wrote onFallback 
first (a natural order, the fallback being the "important" part), the validator 
accepted the file and the run failed with a message that does not mention the 
order.



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

Reply via email to