davsclaus opened a new pull request, #27979: URL: https://github.com/apache/camel/pull/27979
Found while testing the runtime tools for [CAMEL-23688](https://issues.apache.org/jira/browse/CAMEL-23688): **`camel cmd eval` and the tools that evaluate an expression in a running integration corrupt an expression with a double quote or a slash, and a body with quotes.** ### The bug `camel cmd eval` (`EvalExpressionCommand`), the `eval_expression` tool of `camel ask` (`ToolRegistry`) and the shared `ExpressionEvaluator` (the `camel_eval_expression` tool of `camel mcp` and `camel tui --mcp`, when an integration is selected) put the expression and the body in the action with `Jsoner.escape(...)`. The action file is JSON already, and the `eval` action of the CLI connector reads the values as they are (unlike the `transform` action, which unescapes what `camel transform message` escapes). So the integration got `${body} == \"hello\"`: ``` Binary operator == does not accept \"hello\" on the right hand side: write it as a quoted literal 'x', ... ``` A slash became `\/`, which breaks every XPath (`/order/id`), and a JSON body `{"id":1}` reached the expression as `{\"id\":1}`. This has been so since `camel cmd eval` was added (CAMEL-22935). An agent that tests an expression against a running integration got a wrong failure, or a wrong result. ### The fix The three clients send the expression and the body as they are. The connector is unchanged, so integrations of older Camel versions get the right values too. ### Tests - `EvalInTheIntegrationTest` (new): a fake integration answers the `eval` action as the CLI connector does, with the real `eval-language` dev console of a Camel context: an expression with quotes and a slash (`${body} contains "/"`), a JSON body, and the `eval_expression` tool of `camel ask` (the text `"a/b"` comes back with its quotes and slash). - `EvalExpressionResultTest`: `camel cmd eval` sends such an expression and body as given. - `ToolRegistryTest.theHttpToolsAreInternal` used the home directory of the machine, and selected the integration running there, if exactly one runs; it uses a home of its own now. Without the fix, the 4 new tests fail (one with the error above). The change is in the 4.24 upgrade guide. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My -- 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]
