Adriano Machado created CAMEL-23863:
---------------------------------------

             Summary: camel run --example=rest-api fails to start: invalid YAML 
in bundled rest-api example
                 Key: CAMEL-23863
                 URL: https://issues.apache.org/jira/browse/CAMEL-23863
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
    Affects Versions: 4.21.0
            Reporter: Adriano Machado


Running the bundled rest\-api example fails at startup:

{code}
camel run \-\-example=rest\-api
{code}

{code}
ERROR ... org.apache.camel.main.MainSupport : Error starting Camel:
Error constructing YAML node id: rest
 in file:.../rest\-api.camel.yaml, line 2, column 5:
        path: /api
        \^
{code}

h3. Root cause

The bundled example {{rest\-api.camel.yaml}} placed a {{steps:}} key under 
{{rest:}} and defined verbs without a {{to:}} target. {{steps}} is not a valid 
property of the REST DSL {{}} element; verbs 
\({{get}}/{{post}}/{{put}}/{{delete}}\) must be direct children of {{rest}}, 
each a list whose entries carry a {{to:}} target. The failure happens during 
route\-model construction \(not pure YAML parsing\), which is why the reported 
position points at the first child line of the {{rest}} node rather than at the 
offending key.

h3. Steps to reproduceh1. {{camel run \-\-example=rest\-api}}
h1. Observe the {{Error constructing YAML node id: rest}} startup failure.
h3. Expected

The example starts and serves {{GET /api/hello}} and {{GET /api/hello/{name}}}.

h3. Fix

* Correct the verb structure in 
{{dsl/camel\-jbang/camel\-jbang\-core/src/main/resources/examples/rest\-api/rest\-api.camel.yaml}}
 \(verbs as children of {{rest}} with {{to:}} targets pointing at 
{{direct:hello}} / {{direct:hello\-name}}\).
* Add a generic parameterized test \({{ExampleRoutesLoadTest}}\) that loads 
every bundled example through the routes loader, guarding all examples against 
this class of regression.

_Reported by Claude Code on behalf of Adriano Machado._





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

Reply via email to