davsclaus opened a new pull request, #29913: URL: https://github.com/apache/camel/pull/29913
Item 4 of [CAMEL-26930](https://issues.apache.org/jira/browse/CAMEL-26930). ## Problem When `camel run` cannot start the integration, such as for a route that cannot be created, it exits with 70 and prints the stack trace twice: in the log on stdout, and again on stderr. `CliExecutionExceptionHandler` maps any exception that is not a CLI exception to 70. `KameletMainIntegration.start` rethrows the startup failure as it is. `camel-jbang-exit-codes.adoc` says 70 is "most often a bug in Camel ... do not retry", and 1 is "fix the route, the configuration or the input". So an AI agent gives up instead of fixing its route. On the launcher from main, with a route without steps: ``` $ camel run broken.yaml; echo $? 70 (stdout: 44 frames in the log; stderr: 48 lines, the same 44 frames) ``` The existing assertion in `RunTest` (a `FailedToStartRouteException` maps to `INTERNAL`) came with the ProjectRunner refactor (CAMEL-24726). It recorded what the generic handler did, not a decision for 70. ## Change - `KameletMainIntegration.start` wraps an exception from `main.start()` in a new `IntegrationStartException` (in `camel-jbang-run`, which cannot use the `CliException` of core). Its message is the cause's message, and the run's previous-log record gets the new exit code. - `CliExecutionExceptionHandler` maps `IntegrationStartException` to exit 1 with one `ERROR:` line. The stack trace is printed only with `--verbose` or `CAMEL_CLI_DEBUG=true`, since the log already has it. - An `Error` (such as `NoClassDefFoundError`) and `--ignore-loading-error` are unchanged. - `camel-jbang-exit-codes.adoc` lists this under exit 1, and the 4.24 upgrade guide has an entry (scripts that checked for 70 should check for 1). After, on the launcher with the patched jars: ``` $ camel run broken.yaml; echo $? 1 (stdout: the log with the trace once; stderr: one line) ERROR: Failed to create route: nosteps (source: file:broken.yaml) at: >>> From[timer:tick] <<< ... because: Route nosteps has no output processors. ... ``` `camel run broken.yaml --background` also exits 1, with "startup failure" and the log, as before. ## Tests - `CliExecutionExceptionHandlerTest`: the exit code is 1, and stderr has one line without a stack trace. - `RunTest`: the failure exit code of a run is 1 for an `IntegrationStartException`. - End to end with the launcher, as above. - `PreviousRunLogTest`: the start failure is the new exception, with the original as its cause. - camel-jbang-run: 303 tests pass. camel-jbang-core: 2999 + 259 pass (`DependencyUpdateTest` failed once and passed on the rerun, as on other branches). _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
