[
https://issues.apache.org/jira/browse/CAMEL-25493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125499#comment-18125499
]
Federico Mariani commented on CAMEL-25493:
------------------------------------------
Not fixed by the CAMEL-25490 PRs
([#27609|https://github.com/apache/camel/pull/27609],
[#27610|https://github.com/apache/camel/pull/27610]). The suggested fix (write
the builder level error handler once as a top-level {{errorHandler}}) follows
the same pattern as #27609 and should be done on top of it: like the top-level
{{onException}}, it has to come before the routes, which in the multi-file case
relies on the grouping change #27609 makes in {{DefaultDumpRoutesStrategy}}.
Note that merging several files into one widens a file level error handler to
the routes of all the files, as for {{onException}}.
_Claude Code on behalf of Croway_
> camel-yaml-io - YAML route dump drops a top-level errorHandler
> --------------------------------------------------------------
>
> Key: CAMEL-25493
> URL: https://issues.apache.org/jira/browse/CAMEL-25493
> Project: Camel
> Issue Type: Bug
> Components: camel-jbang, camel-yaml-dsl
> Affects Versions: 4.22.1
> Reporter: Federico Mariani
> Assignee: Federico Mariani
> Priority: Major
>
> {{camel validate normalize}} (the YAML route dump,
> {{camel.main.dumpRoutes=yaml}}) drops a top-level {{errorHandler}}: the
> normalized file loads and validates, but the routes silently lose their error
> handler (here a dead letter channel falls back to the default error handler).
> h3. Reproduction (Camel CLI 4.22.1, same on main)
> {code:yaml|title=in.yaml}
> - errorHandler:
> deadLetterChannel:
> deadLetterUri: log:dead
> - route:
> id: myRoute
> from:
> uri: direct:start
> steps:
> - to: log:out
> {code}
> {{camel validate normalize in.yaml}}:
> {code:yaml}
> - route:
> id: myRoute
> from:
> uri: direct
> parameters:
> name: start
> steps:
> - to:
> uri: log
> parameters:
> loggerName: out
> {code}
> No error is reported; the {{errorHandler}} is gone.
> h3. Cause
> The YAML DSL loader passes a top-level {{errorHandler}} to
> {{RouteBuilder.errorHandler(ErrorHandlerFactory)}}
> ({{YamlRoutesBuilderLoader}}), and {{RoutesDefinition.route(...)}} sets it on
> each route with {{RouteDefinition.setErrorHandlerFactoryIfNull}}. That sets
> only the {{errorHandlerFactory}} field, not the {{errorHandler}}
> ({{ErrorHandlerDefinition}}) property, and the YAML writer
> ({{YamlModelWriter.doWriteRouteDefinition}}) writes only
> {{getErrorHandler()}}. A route level {{errorHandler}} set with
> {{setErrorHandler}} is written; the builder level one is not.
> A fix could write the error handler factory of the routes, when it is a model
> {{ErrorHandlerDefinition}} that was not set on the route itself, as a
> top-level {{errorHandler}} (once, as for the onException of CAMEL-25490).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)