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

   JIRA: [CAMEL-27365](https://issues.apache.org/jira/browse/CAMEL-27365)
   
   ## What was wrong
   
   `camel validate` (Camel CLI) checks that the `include` and `exclude` options 
of the file components (file, ftp, sftp, ...) compile as regular expressions 
(`EndpointChecks.checkRegexOptions` in `camel-jbang-core`). The check skipped a 
value that starts with `{{`, but not one inside `RAW()`. The `sftp-source` 
Kamelet (and the new `smb-source` one) has `include: "RAW({{?include}})"`, so 
the check compiled `RAW({{?include}})` as a regex and reported a false error:
   
   ```
   Line 271: sftp: include=RAW({{?include}}) is not a regular expression 
(Illegal repetition): include is a regex, write 
include=RAW\(\{\{.include\}\}\), or use the wildcard option 
antInclude=RAW({{?include}})
   ```
   
   ## The fix
   
   - A value that has a property placeholder anywhere is not checked as a 
regex: its value is only known at runtime.
   - The check now looks at the value inside `RAW(...)` or `RAW{...}`, because 
`RAW` is not part of the regex. So `include=RAW(*.txt)` is still reported, as 
`*.txt`.
   
   ## Tests
   
   - New 
`SourceValidatorEndpointTest#aPlaceholderInTheFileIncludeOptionIsNotCheckedAsARegex`.
 It covers `RAW({{?include}})` and `RAW({{?exclude}})` under `parameters:` on 
sftp, and `{{prefix}}*` and `RAW({{?exclude}})` in a file uri, which get no 
report. It also checks that `RAW(*.txt)` is still reported. It fails without 
the fix.
   - Ran `SourceValidator*Test`, `KameletChecksTest` in `camel-jbang-core`: 258 
tests, 0 failures.
   - Checked by hand with the real `sftp-source.kamelet.yaml` from 
camel-kamelets through `SourceValidator.validateYamlCatalog`, which is what 
`camel validate` runs. Before the fix it reported the 2 regex messages above 
(lines 267 and 271). After the fix it reports nothing.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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