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


##########
core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java:
##########
@@ -1408,20 +1419,65 @@ private static boolean isValidSuffix(String suffix) {
         return suffix == null || suffix.isEmpty() || suffix.equals(".");
     }
 
-    private static boolean acceptConfigurationPropertyKey(String key) {
+    private boolean acceptConfigurationPropertyKey(String key, MainModel 
cachedModel) {
         if (key == null) {
             return false;
         }
-        return key.startsWith("camel.component.")
+        // Keys outside the camel.* namespace are never checked by this catalog
+        if (!key.startsWith("camel.")) {
+            return false;
+        }
+        // Always-accepted static prefixes (component/dataformat/language have 
their own models)
+        if (key.startsWith("camel.component.")
                 || key.startsWith("camel.dataformat.")
-                || key.startsWith("camel.language.")
-                || key.startsWith("camel.main.")
-                || key.startsWith("camel.resilience4j.")
-                || key.startsWith("camel.faulttolerance.")
-                || key.startsWith("camel.threadpool.")
-                || key.startsWith("camel.health.")
-                || key.startsWith("camel.lra.")
-                || key.startsWith("camel.rest.");
+                || key.startsWith("camel.language.")) {
+            return true;
+        }
+        // Dynamic: accept any prefix that matches a group in the main-model 
metadata.
+        // camel-main binds keys after normalising dashes and case 
(MainHelper.optionKey /
+        // startsWithIgnoreCase), so we compare normalised forms to match e.g.
+        // camel.error-registry.* against the group name "camel.errorRegistry".
+        String normKey = key.replace("-", "").toLowerCase(Locale.ENGLISH);
+        MainModel model = cachedModel;
+        if (model != null) {
+            for (MainModel.MainGroupModel group : model.getGroups()) {
+                String normGroup = group.getName().replace("-", 
"").toLowerCase(Locale.ENGLISH) + ".";
+                if (normKey.startsWith(normGroup)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns the matched group from the main-model metadata when the key 
(with the leading {@code camel.} stripped)
+     * corresponds to one of the registered groups, or {@code null} if no 
group matches.
+     * <p>
+     * Comparison is normalised (dashes removed, lower-cased) to mirror how 
camel-main binds keys at runtime via
+     * {@code MainHelper.optionKey} and {@code startsWithIgnoreCase}.
+     * <p>
+     * Note: {@link #acceptConfigurationPropertyKey} also iterates the groups 
with the same normalisation, but it
+     * receives the full {@code camel.*} key (not the stripped form) and 
returns a boolean rather than the matched
+     * group. A direct delegation is awkward because the two callers need 
different key conventions, so both methods are
+     * kept separate and share the normalisation comment above.
+     */
+    private MainModel.MainGroupModel matchMainModelGroup(String key, MainModel 
cachedModel) {
+        MainModel model = cachedModel;
+        if (model == null) {
+            return null;
+        }
+        // Normalise the incoming key once
+        String normKey = key.replace("-", "").toLowerCase(Locale.ENGLISH);
+        for (MainModel.MainGroupModel group : model.getGroups()) {
+            // group name is e.g. "camel.server" — strip the leading "camel." 
to get "server"
+            String groupName = group.getName().substring("camel.".length());
+            String normGroupName = groupName.replace("-", 
"").toLowerCase(Locale.ENGLISH);
+            if (normKey.startsWith(normGroupName + ".")) {

Review Comment:
   ⚠️ **Bug: `normKey` still carries the `"camel."` prefix but `normGroupName` 
does not — `startsWith` always fails.**
   
   `normKey` = `"camel.errorregistry.enabled"` (full key, as passed by the 
caller).
   `groupName` = `group.getName().substring("camel.".length())` = 
`"errorRegistry"` → `normGroupName` = `"errorregistry"`.
   `"camel.errorregistry.enabled".startsWith("errorregistry.")` → **`false`**.
   
   The `for` loop never returns a non-null group; `matchMainModelGroup` always 
returns `null`; the `else` branch in `validateConfigurationProperty` never 
executes → unknown options under accepted groups are silently ignored (no 
validation error raised).
   
   `acceptConfigurationPropertyKey` avoids this because it uses 
`group.getName()` directly (the full `"camel.errorRegistry"` string), not the 
stripped form. Apply the same pattern here:
   
   ```suggestion
           for (MainModel.MainGroupModel group : model.getGroups()) {
               String normGroup = group.getName().replace("-", 
"").toLowerCase(Locale.ENGLISH) + ".";
               if (normKey.startsWith(normGroup)) {
                   return group;
               }
           }
   ```



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