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

   Resolves [CAMEL-24715](https://issues.apache.org/jira/browse/CAMEL-24715). 
Tidy-up promised on CAMEL-24698 / PR #26362.
   
   ## Validator: rows instead of branches
   
   The four hint methods of `YamlValidator` (`withStepHints`, 
`withExpressionHint`, `withListHint`, `withPropertyHint`) and 
`compactNotationHint` each grew as an `if` chain keyed on the error's keyword, 
a location regex and a message substring, with the same `Error.builder()` 
boilerplate copied 22 times. They are now five tables in a new package-private 
`SchemaHints` class — `STEP`, `EXPRESSION`, `LIST`, `PROPERTY`, `COMPACT` — 
where a row is `(keyword, location pattern, condition, text)`:
   
   ```java
   unknownProperty(".*/log", m -> m.unknown().equals("level") || 
m.unknown().equals("logLevel"),
           m -> "did you mean 'loggingLevel'?"),
   ```
   
   One matcher (`SchemaHints.apply`) selects the first row that matches and 
builds the rewritten `Error` in one place; `validate()` calls the five tables 
in the same order as before. A `Match` record hands each row the pieces every 
branch used to recompute (location, last segment, parent key, the unknown 
property name, the validator's schema-derived sets). Rows are functions rather 
than plain strings because most hints interpolate the offending name or the 
closest known property.
   
   Behaviour-neutral: the 97 existing `YamlValidator*Test` / 
`YamlCanonicalValidatorTest` / `EipDocExamplesTest` tests pin every message and 
pass unchanged, as do the camel-jbang-core, -mcp and -tui tests that assert on 
hint texts. `YamlValidator` goes from 1328 to 941 lines. A new 
`SchemaHintsTest` pins the matcher itself (first match wins, 
keyword/location/condition selection, replace vs append, dedupe of identical 
rewrites).
   
   ## camel-jbang: drift test for the hardcoded lists
   
   `ChecksCatalogDriftTest` cross-checks the lists the write-time checks carry 
that the catalog has no metadata for, and names every drifted entry in one run:
   
   - `EndpointChecks.INVENTED_OPTIONS` — each `scheme:option` must **not** be 
an endpoint or component option of that component in the catalog (the day it 
is, the hint tells the user to remove an option that works).
   - `HeaderChecks.EXCHANGE_PROPERTIES` — each timer name must be an 
`Exchange.TIMER_*` constant and must not be listed as a header of that 
component in the catalog.
   - `BeanRefChecks.REQUIRED_TYPES` — the no-catalog fallback must agree with 
the catalog-derived map.
   
   The last check found real drift on its first run: `strategyRef` and 
`processorRef` are Camel 2/3 XML attribute names — no Camel 4 model, XML parser 
or YAML schema has them, so the catalog-derived map (rightly) had no entry — 
and `processor` is not an option name of any EIP model either. The fallback now 
holds the one entry the catalog confirms (`aggregationStrategy`). The 
bean-reference *pattern* still recognises the old names as reference lines; 
that is about which lines get a "bean not found" check and is deliberately 
wider than the catalog, so it is untouched.
   
   `LOG_COMPONENT_OPTIONS` (now in `SchemaHints`) is the one remaining list not 
covered: the validator module has no catalog dependency, and the log 
component's option set is stable; noted rather than adding a dependency for it.
   
   ## Tests
   
   - `camel-yaml-dsl-validator`: 103 tests (97 existing + 6 new), green.
   - `camel-jbang-core`: `ChecksCatalogDriftTest`, `SourceValidator*Test`, 
`AuthoringToolsTest`, `ExampleRoutesLoadTest` — 131 tests, green.
   - `camel-jbang-mcp` (`AiPipelineScaffoldToolsTest`, `OpenApiToolsTest`, 
`ConfigurationValidateToolsTest`) and `camel-jbang-plugin-tui` 
(`SourceEditAssistValidateTest`) — green.
   
   No user-facing behaviour or documentation change; nothing for the upgrade 
guide.
   
   _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