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

   ## Description
   
   When a YAML route file fails to load, `camel run` printed the loader's 
message, "Error constructing YAML node id: pollEnrich: unsupported field: uri", 
which knows the field is wrong but not what to write. The schema validator 
(camel-yaml-dsl-validator, already a dependency of camel-jbang-core) has the 
message that says what to write, with its hints, but `camel run` never called 
it. In the round-2 benchmark 54 of 67 startup failures had such a message that 
was never shown, because the file was run without validating first; people 
prototyping with the CLI do the same.
   
   Now, before the loader's error:
   
   ```
   ERROR ... YamlLoadFailureReport : The route file did not load. camel 
validate yaml says what to write:
     orders.camel.yaml:
       pollEnrich: property 'uri' is not defined in the schema and the schema 
does not allow additional properties
     (camel validate yaml <file> for the full report; the loader's error 
follows)
   ERROR ... MainSupport : Error starting Camel: Error constructing YAML node 
id: pollEnrich: unsupported field: uri
   ```
   
   (with #26633 in, the first line becomes `write pollEnrich: {expression: 
{constant: ...}}`.) The same report on a failed reload in `--dev` mode, next to 
the file watcher's warning.
   
   - `YamlLoadFailureReport` (camel-jbang-core): recognises a YAML load failure 
in the cause chain (`YamlDeserializationException`, "Error pre-parsing 
resource"), runs `SourceValidator` on the run's local YAML files and logs the 
lines. Logged, not printed, so they are in the console and in the run's log 
file alike, which is what the camel-jbang-mcp `camel_get_log` tool reads after 
`camel_run`.
   - `KameletMain.setStartFailureListener(Consumer<Exception>)`: called in 
`doFail` before the error is logged, so the report comes first. `Run` sets it 
with the run's files.
   - `FileWatcherResourceReloadStrategy` (camel-support): a failed reload emits 
the `CamelContextReloadFailure` event, the event a failed context reload 
already emitted, with the file name as the action. `Run` registers an event 
notifier that logs the report for that file. The API is unchanged.
   - The runtime and the loader's messages stay as they are; Spring Boot and 
Quarkus users keep them.
   
   Upgrade guide note added.
   
   ## Tests
   
   - `YamlLoadFailureReportTest`: the failure detection, the report for a bad 
file, no report for a file the validator accepts, the run files filtered to 
local YAML, and the reload notifier on the real event class.
   - Live: `camel run` of a route with `pollEnrich: {uri: ...}` prints the 
report before "Error starting Camel"; `camel run --dev` of a good route, edited 
into the bad one, prints it next to the reload warning.
   - camel-core reload tests (16) and the camel-jbang-core ai package plus 
`RunTest` (239) green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj


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