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


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/ConfigurationValidateTools.java:
##########
@@ -105,16 +130,41 @@ public ConfigurationValidateResult 
camel_configuration_validate(
     }
 
     private PropertyValidationInfo toPropertyValidationInfo(
-            int lineNumber, String text, 
ConfigurationPropertiesValidationResult result) {
-        boolean valid = result.isSuccess();
-        boolean accepted = result.isAccepted();
-        int errors = result.getNumberOfErrors();
-        int warnings = result.getNumberOfWarnings();
+            int lineNumber, String text, 
ConfigurationPropertiesValidationResult result, boolean isSpringBoot) {
+        boolean checked = result.isAccepted();
+        // A checked line is valid when the catalog found no errors; an 
unchecked line
+        // (not recognised as a Camel property) is neither valid nor invalid — 
it is simply
+        // not inspected by this catalog.
+        boolean valid = checked && result.isSuccess();
+
+        // For Spring Boot, the catalog uses camel-main metadata which does 
not include
+        // starter-specific options (e.g. camel.metrics.uriTagEnabled from 
camel-micrometer-starter).
+        // When the only issues are "unknown option" errors, downgrade to 
unchecked to avoid
+        // false positives — the starter may legitimately bind options outside 
the main schema.
+        if (isSpringBoot && checked && !valid) {
+            Set<String> unknownKeys = result.getUnknown() != null ? 
result.getUnknown() : Collections.emptySet();
+            boolean onlyUnknownOptionErrors = !unknownKeys.isEmpty()
+                    && result.getNumberOfErrors() == unknownKeys.size()
+                    && result.getSyntaxError() == null
+                    && result.getIncapable() == null
+                    && result.getInvalidBoolean() == null
+                    && result.getInvalidEnum() == null
+                    && result.getInvalidInteger() == null
+                    && result.getInvalidNumber() == null
+                    && result.getInvalidDuration() == null;
+            if (onlyUnknownOptionErrors) {
+                checked = false;
+                valid = false;
+            }

Review Comment:
   💡 **Missing test for Spring Boot downgrade path.** The `isSpringBoot && 
onlyUnknownOptionErrors` branch added in this commit has no test in 
`ConfigurationValidateToolsTest`. A starter-only option (e.g. 
`camel.metrics.uriTagEnabled`) validated with `runtime="spring-boot"` should 
come back as `checked=false, valid=false` — and this isn't exercised anywhere.
   
   Minimal test to add:
   
   ```java
   @Test
   void springBootStarterOnlyOptionIsUnchecked() {
       // camel.metrics.uriTagEnabled exists in camel-micrometer-starter but 
not in the
       // camel-main metadata the catalog uses — it must not be reported as an 
error for
       // runtime=spring-boot.
       ConfigurationValidateTools tools = createTools();
   
       ConfigurationValidateTools.ConfigurationValidateResult result
               = tools.camel_configuration_validate(
                       "camel.metrics.uriTagEnabled=true", "spring-boot", null, 
null);
   
       ConfigurationValidateTools.PropertyValidationInfo info = 
result.properties().get(0);
       assertThat(info.checked()).isFalse();
       assertThat(info.valid()).isFalse();
       assertThat(result.summary().unchecked()).isEqualTo(1);
       assertThat(result.summary().errors()).isZero();
   }
   ```



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