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

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

PR: [#27629|https://github.com/apache/camel/pull/27629]. Besides the five route 
configuration lists, the uri pattern of {{interceptFrom}} / 
{{interceptSendToEndpoint}} was split into {{uri}} + {{parameters}} when the 
uris are dumped as parameters (as {{camel validate normalize}} does), which 
their YAML DSL schema does not allow; the PR writes it as it is. Backport to 
camel-4.22.x after merge.

_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)

Reply via email to