davsclaus opened a new pull request, #29430:
URL: https://github.com/apache/camel/pull/29430

   _Claude Code on behalf of davsclaus_
   
   [CAMEL-26750](https://issues.apache.org/jira/browse/CAMEL-26750)
   
   ## Summary
   
   When a circuit breaker's `onFallback` is loaded from YAML or XML, the steps 
nested inside the fallback get the wrong route ID. Their route shows up as the 
ID of the fallback's first step, both in the message history and in the error 
registry (`camel get errors`, the dev console, the TUI). With the 
`fail-well/circuit-breaker` example, whose fallback holds a `choice`, the 
errors recorded while the breaker is open say `routeId: choice1`, and the 
message history says `choice1[setBody1]` instead of `stock-check[setBody1]`.
   
   **Cause:** a loader builds the `onFallback`, steps included, before setting 
it with `setOnFallback`. Only the fluent `onFallback()` gives the fallback and 
its steps a parent; `setOnFallback` did not. `RouteDefinitionHelper.initParent` 
doesn't reach them either, because the fallback isn't one of the circuit 
breaker's outputs. The message history finds a step's route by walking up its 
parents (`CamelContextHelper.getRouteId`), so for a step inside the choice it 
stopped at the choice.
   
   The copy constructor had the same gap: a copied fallback kept the original 
circuit breaker as its parent, which affects route templates and kamelets. This 
is not a regression of CAMEL-24700: `setOnFallback` never set the parents.
   
   **Fix:** `setOnFallback` and the copy constructor now make the circuit 
breaker the parent of the fallback and its steps, as `onFallback()` does. The 
model is shared, so camel-resilience4j and camel-microprofile-fault-tolerance 
both get the fix.
   
   ## Test plan
   
   - New `ResilienceFallbackRouteIdTest`: builds the fallback the way the 
loaders do, with a `choice` added before the fallback has a parent, and checks 
that every message history entry has the route ID. It fails without the fix 
(`the route of fallbackBody ==> expected: <start> but was: <choice>`).
   - camel-resilience4j (95 tests) and camel-microprofile-fault-tolerance (43 
tests) pass.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to