You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Federico Mariani (Jira)" <ji...@apache.org> on 2026/10/09 11:34:00 UTC

[jira] [Commented] (CAMEL-25494) camel-yaml-io - YAML route dump writes routeConfiguration onException items without their onException key, which neither the schema nor the loader accept

    [ https://issues.apache.org/jira/browse/CAMEL-25494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125500#comment-18125500 ] 

Federico Mariani commented on CAMEL-25494:
------------------------------------------

Not fixed by the CAMEL-25490 PRs ([#27609|https://github.com/apache/camel/pull/27609], [#27610|https://github.com/apache/camel/pull/27610]), and independent of them (generated {{YamlModelWriter}}, not {{LwModelToYAMLDumper}}). Related: #27609 merges the files of {{camel validate normalize a.yaml b.yaml}} into one file, so a top-level {{onException}} of one file then applies to the routes of all of them. Keeping the original scope would need a {{routeConfiguration}} with an id for that file's routes, which only round-trips once this issue is fixed.

_Claude Code on behalf of Croway_

> camel-yaml-io - YAML route dump writes routeConfiguration onException items without their onException key, which neither the schema nor the loader accept
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25494
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25494
>             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}}) writes the {{onException}} items of a {{routeConfiguration}} without their {{onException:}} key. The result is rejected by the YAML DSL schema, and the runtime does not load it either.
> h3. Reproduction (Camel CLI 4.22.1, same on main)
> {code:yaml|title=in.yaml}
> - routeConfiguration:
>     id: myConfig
>     onException:
>       - onException:
>           exception:
>             - java.lang.Exception
>           handled:
>             constant: "true"
>           steps:
>             - log:
>                 message: "failed"
> - route:
>     id: myRoute
>     from:
>       uri: direct:start
>       steps:
>         - log:
>             message: "Hello"
> {code}
> {{camel validate yaml in.yaml}}: Validation success. {{camel validate normalize in.yaml --output=out.yaml}}:
> {code:yaml|title=out.yaml}
> - routeConfiguration:
>     id: myConfig
>     onException:
>       - exception:
>           - java.lang.Exception
>         handled:
>           constant:
>             expression: "true"
>         steps:
>           - log:
>               message: failed
> - route:
>     id: myRoute
>     from:
>       uri: direct
>       parameters:
>         name: start
>       steps:
>         - log:
>             message: Hello
> {code}
> {noformat}
> $ camel validate yaml out.yaml
> Validation error detected (errors:3)
> 	File: out.yaml
> 		/0/routeConfiguration/onException/0: property 'exception' is not defined in the schema and the schema does not allow additional properties
> 		/0/routeConfiguration/onException/0: property 'handled' is not defined in the schema and the schema does not allow additional properties
> 		/0/routeConfiguration/onException/0: property 'steps' is not defined in the schema and the schema does not allow additional properties
> $ camel run out.yaml
> ERROR ... Error starting Camel: Node should have only have 1 key, was: 3 keys: [exception,handled,steps] (Maybe this is an indent problem in the YAML source).
> {noformat}
> h3. Cause
> The generated {{YamlModelWriter.doWriteRouteConfigurationDefinition}} (core/camel-yaml-io, generated by camel-package-maven-plugin) writes the {{onException}}, {{intercept}}, {{interceptFrom}}, {{interceptSendToEndpoint}} and {{onCompletion}} lists of a route configuration as lists of bare objects, while the YAML DSL reads each item as a one-key map ({{- onException: ...}}, {{- intercept: ...}}). The same likely applies to the other lists of the route configuration (the {{intercept}} list is written as {{- steps: ...}}).
> The existing writer test expects the wrong form: {{core/camel-yaml-io/src/test/resources/yaml-routeconfig.yaml}} (used by {{YamlModelWriterTest.testRouteConfiguration}}) has {{onException: - exception: ...}} and {{intercept: - steps: ...}}, so it has to be changed with the fix.



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