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

   Follow-up to #26349 — **stacked on top of it**, so this PR targets 
`fix/CAMEL-24692` and should be merged after it. Part of 
[CAMEL-24692](https://issues.apache.org/jira/browse/CAMEL-24692).
   
   ## Background
   
   The TUI save-time validation carried a workaround for the catalog bug fixed 
in #26349:
   
   ```java
   // Skip placeholder-only expressions
   if (simpleText.startsWith("{{") && simpleText.endsWith("}}")) {
       continue;
   }
   ```
   
   The obvious follow-up was to delete it. **That turns out not to be safe**, 
so this PR narrows it instead.
   
   ## Why it cannot just be removed
   
   A property placeholder can expand to an entire *predicate*, not just a 
value. The catalog substitutes a placeholder with a dummy value, which is what 
an operand of a binary operator needs, but a logical operator needs a predicate 
on either side. So these still fail validation, checked against the catalog 
built from #26349:
   
   ```
   {{a}} && {{b}}            -> Logical operator && does not support left hand 
side token '
   {{a}} and {{b}}           -> Unexpected token a
   ```
   
   Those are false positives: at runtime the placeholders resolve first, so 
`{{enabled}} && ${body} > 1` is a perfectly valid route. Deleting the guard 
would reintroduce exactly the class of false positive CAMEL-24692 is about.
   
   ## What this PR does
   
   Replaces the shape-based guard with a check for the one case the catalog 
genuinely cannot model — a placeholder used as an operand of a logical 
operator. The new guard is **narrower in one direction and wider in the other**:
   
   - Expressions that are merely placeholder-valued are now validated instead 
of skipped, so real errors in them get caught. `{{a}} =!= {{b}}` was silently 
ignored before.
   - It also covers a case the old guard missed. `${body} > 1 && {{flag}}` does 
not start with `{{`, so it was never skipped and was already reported as a 
false error, independently of CAMEL-24692.
   
   | expression | before | after |
   |---|---|---|
   | `{{hot.threshold}}` | skipped | validated (passes) |
   | `${body} >= {{hot.threshold}}` | validated (false error) | validated 
(passes) |
   | `{{a}} =!= {{b}}` | skipped (real error hidden) | validated (error 
reported) |
   | `{{a}} && {{b}}` | skipped | skipped |
   | `${body} > 1 && {{flag}}` | validated (false error) | skipped |
   
   The operand split ignores quoted literals, so a `&&` inside a string is not 
treated as an operator.
   
   ## Testing
   
   Three new tests in `SourceEditAssistValidateTest`: one pinning what must now 
be validated, one pinning what must still be skipped (including the 
quoted-literal case), and an end-to-end one running `validateSource` over a 
YAML route that uses both placeholder shapes under `choice`/`when`. 7/7 pass in 
that class.
   
   ---
   _Claude Code on behalf of davsclaus_
   


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