ammachado opened a new pull request, #26615: URL: https://github.com/apache/camel/pull/26615
# Description [CAMEL-24845](https://issues.apache.org/jira/browse/CAMEL-24845). Writing a jsonpath inside Simple the way the other colon functions are written: ```yaml - filter: simple: "${jsonpath:$.status} == 'paid'" ``` `camel validate yaml` and the runtime both answer: ``` Line 8: Simple syntax error: Unknown function: jsonpath:$.status (did you mean ${jsonpath:$.status}?) ``` The suggestion is the text that was just rejected, so the reader, human or model, writes it again. The working form is the function call `${jsonpath($.status)}`. ## Root cause `SimpleSyntaxHints.unknownFunction` assembles the did-you-mean from `closest()`, whose longest-known-prefix branch returns the name **itself** when the name is a known function. `functionName()` stops at the colon, so `jsonpath:$.status` yields the name `jsonpath`, which matches itself, and the hint is rebuilt into the original text. Nothing asserted that the suggestion differed from what was written, so the failure is an identity rewrite rather than a bad match. ## Changes - `jq`, `jsonpath`, `xpath` and `simpleJsonpath` take their argument in parentheses and have no colon form, unlike `bean:`, `date:`, `env:` and friends. The colon shape now suggests `${jsonpath($.status)}`, and the bare name suggests `${jsonpath(exp)}`. - The `json` alias resolves to `jsonpath`, so `${json:$.status}` had to move its argument into parentheses too; previously it suggested the invalid `${jsonpath:$.status}`. - A suggestion equal to the rejected text is never returned. `${bean:myBean}` and `${date:now:HH:mm}` fall into the same trap and echo themselves; they are valid syntax so the parser resolves them first, which is why this was latent rather than reported. - Dropped `jsonpath`, `xpath` and `jq` from the "is a language, not a simple function: another language cannot be nested inside `${...}`" message. `QueryLanguageFunctionFactory` (CAMEL-22894) made all four Simple functions of their own, so for `${jsonpath}` that advice was the opposite of what the author needs. `groovy`, `xquery`, `mvel`, `ognl`, `spel`, `js`, `python`, `java`, `constant`, `tokenize` and `method` stay, since those are still only usable under their own key. ## Before / after | Input | Before | After | |---|---|---| | `${jsonpath:$.status}` | `did you mean ${jsonpath:$.status}?` | `the argument goes in parentheses: did you mean ${jsonpath($.status)}?` | | `${jq:.name}` | *(no hint at all)* | `...did you mean ${jq(.name)}?` | | `${xpath:/order/@id}` | `did you mean ${xpath:/order/@id}?` | `...did you mean ${xpath(/order/@id)}?` | | `${json:$.status}` | `did you mean ${jsonpath:$.status}?` | `...did you mean ${jsonpath($.status)}?` | | `${jsonpath}` | `jsonpath is a language, not a simple function...` | `...did you mean ${jsonpath(exp)}?` | | `${bean:myBean}` | `did you mean ${bean:myBean}?` | points at the simple language page | `${jsonpath($.status)}` itself is unaffected: it is resolved by `SimpleFunctionDispatcher.tryCreateBuiltIn` and never reaches the hint. Three new tests in `SimpleSyntaxHintsTest`, each of which fails on `main` with the message from the ticket. No upgrade guide entry: this changes the wording of a parser error, not behaviour anyone migrates around. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. > Not run from the root folder. What was run: `mvn formatter:format impsort:sort` on `core/camel-core-languages` and `core/camel-core` (no further changes produced), and `mvn -pl core/camel-core test -Dtest='org.apache.camel.language.**'` (768 tests, 0 failures, 1 pre-existing skip). The change touches two hand-written Java files with no catalog or component metadata behind them, so no generated files are expected, but I have not proven that with the full root build and am relying on CI's uncommitted-changes check. # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. _Claude Code on behalf of Adriano Machado (@ammachado)_ _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._ -- 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]
