davsclaus commented on code in PR #26621:
URL: https://github.com/apache/camel/pull/26621#discussion_r4056559479


##########
components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java:
##########
@@ -212,8 +219,26 @@ public void init(CamelContext context) {
             engine = new JsonPathEngine(
                     exp, source, writeAsString, suppressExceptions, 
allowSimple, options, context);
         } catch (Exception e) {
-            throw new ExpressionIllegalSyntaxException(exp, e);
+            String hint = comparisonHint(exp);
+            throw new ExpressionIllegalSyntaxException(hint != null ? exp + " 
(" + hint + ")" : exp, e);
+        }
+    }
+
+    /**
+     * The hint for a comparison written on the path ($.status == 'paid') 
where a path is expected: as a predicate it is
+     * read as a condition (the easy predicate syntax); as an expression it is 
not a path (CAMEL-24841).
+     */
+    static String comparisonHint(String exp) {
+        if (exp == null || exp.contains("[?(") || 
!EasyPredicateOperators.hasOperator(exp)) {
+            return null;
         }

Review Comment:
   Applied, and mirrored in the validator check in camel-jbang-core 
(JsonPathChecks), which builds the same sentence: the Simple form is offered 
for a top-level field only, since `${body[key]}` reads one key of a Map. A 
nested path keeps the filter form alone. Tests: JsonPathComparisonHintTest 
(top-level, nested, paths and filters) and a nested case in JsonPathChecksTest. 
Commit 0a86192574f8.



##########
components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/easypredicate/EasyPredicateOperators.java:
##########
@@ -44,7 +44,7 @@ private EasyPredicateOperators() {
     /**
      * Does the expression have any operator (with single space around)?
      */
-    static boolean hasOperator(String exp) {
+    public static boolean hasOperator(String exp) {

Review Comment:
   Added, with the param and return, in the same commit (0a86192574f8).



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