gnodet-bot commented on code in PR #26616:
URL: https://github.com/apache/camel/pull/26616#discussion_r4055701575


##########
core/camel-core-languages/src/main/docs/modules/languages/pages/simple-operators.adoc:
##########
@@ -123,16 +123,29 @@ The syntax for the ternary operator is:
 
 [source,text]
 ----
-${leftValue} OP rightValue ? trueValue : falseValue
+${leftValue OP rightValue ? trueValue : falseValue}
 ----
 
+The whole ternary must be inside a single `${ }`. Outside `${ }` a Simple 
expression is a template,
+so a `?` and a `:` there are literal text and the operator is not evaluated. 
For example
+`${body.size()} == 0 ? ${null} : ${body[0]}` is not a ternary: it returns the 
text

Review Comment:
   ⚠️ **CI failure root cause:** AsciiDoc processes `{null}` and `{body[0]}` as 
attribute references inside inline backtick spans (they are NOT protected like 
`[source]` blocks). This produces the `Validate documentation` CI failure: 
`skipping reference to missing attribute: null`.
   
   Fix with `+...+` passthrough to suppress attribute substitution:
   
   ```suggestion
   `+${body.size()}+` == 0 ? `+${null}+` : `+${body[0]}+` is not a ternary: it 
returns the text
   ```



##########
catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-operators.adoc:
##########
@@ -123,16 +123,29 @@ The syntax for the ternary operator is:
 
 [source,text]
 ----
-${leftValue} OP rightValue ? trueValue : falseValue
+${leftValue OP rightValue ? trueValue : falseValue}
 ----
 
+The whole ternary must be inside a single `${ }`. Outside `${ }` a Simple 
expression is a template,
+so a `?` and a `:` there are literal text and the operator is not evaluated. 
For example
+`${body.size()} == 0 ? ${null} : ${body[0]}` is not a ternary: it returns the 
text

Review Comment:
   ⚠️ **Same AsciiDoc attribute substitution bug** in the generated copy — 
`{null}` and `{body[0]}` will be treated as attribute references.
   
   ```suggestion
   `+${body.size()}+` == 0 ? `+${null}+` : `+${body[0]}+` is not a ternary: it 
returns the text
   ```



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/SimpleChecks.java:
##########
@@ -102,24 +102,85 @@ else if (key.startsWith("message:") && 
!key.equals("message:")) {
             // Determine predicate vs expression context
             boolean predicate = !isLogMessage && isPredicate(catalog, lines, 
i, lineIndent);
 
+            boolean parsed = true;
             try {
                 LanguageValidationResult result = predicate
                         ? catalog.validateLanguagePredicate(null, "simple", 
simpleText)
                         : catalog.validateLanguageExpression(null, "simple", 
simpleText);
                 if (!result.isSuccess()) {
                     String error = result.getShortError() != null ? 
result.getShortError() : result.getError();
                     if (error != null && !isMissingDependency(error)) {
+                        parsed = false;
                         errors.add("Line " + lineNum + ": Simple syntax error: 
" + error
                                    + aggregatedSizeHint(error, lines, i, 
lineIndent));
                     }
                 }
             } catch (Exception e) {
                 // best effort
             }
+

Review Comment:
   💡 **Minor — `parsed` flag is misleading when the catalog throws:** The 
variable is named `parsed` but its meaning is "no syntax error was reported". 
When `catalog.validateLanguage*` throws an `Exception`, the catch block 
silently swallows it and `parsed` stays `true`, so `topLevelTernary()` fires on 
an expression the catalog couldn't even evaluate — potentially emitting a 
ternary hint on an expression that has entirely different problems.
   
   Consider setting `parsed = false` in the catch block as well (or rename to 
`noSyntaxError` and set it to `false` on exception), so the ternary check 
doesn't fire when the catalog itself crashed:
   
   ```suggestion
               } catch (Exception e) {
                   // best effort
                   parsed = false;
               }
   ```



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