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

   [CAMEL-26863](https://issues.apache.org/jira/browse/CAMEL-26863): every 
command typed in the shell panel of `camel tui` (F6) fails with
   
   ```
   java.lang.NullPointerException: Cannot read field "versionHelpRequested" 
because "x0" is null
        at 
picocli.CommandLine$Interpreter.isAnyHelpRequested(CommandLine.java:14851)
        at picocli.CommandLine$Interpreter.parse(CommandLine.java:13640)
   ```
   
   `ps`, `version`, `get route`, `ask ...`: all of them. `camel shell` is fine.
   
   ## Cause
   
   Since CAMEL-26440 (#28774) the shell panel builds the commands with 
`CamelJBangMain.newCommandLine()`, a fresh root command line that is never 
parsed. The shell runs a sub-command directly, and picocli then asks each 
parent command whether help was requested 
(`parsed.getParent().interpreter.isAnyHelpRequested()`); the root has no parse 
result, hence the NPE. `camel shell` hands over the command line that ran 
`camel shell`, whose root is parsed.
   
   ## Fix
   
   `CamelShellCommandRegistry` parses a command line that has no parse result 
yet once with no arguments. A command line that was parsed (`camel shell`) 
keeps its parse result.
   
   ## Testing
   
   - `CamelShellCommandRegistryTest`: a command runs on a command line that was 
never parsed, directly and after `camel` (fails without the fix), and the parse 
result of a parsed command line is kept.
   - camel-jbang-core tests pass 
(`ExportApiTest.repeatedExportsReleaseTheirSilentRuns` failed once and passed 
on the retry; it passes alone, and does not use the shell).
   - Manually, a launcher built from this branch: in the shell panel `ps`, 
`version`, `camel get route`, `version --help` and `ask who are you` work (the 
last one says no LLM service is reachable, as `camel ask` does).
   
   _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]

Reply via email to