This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7c3eb36e4a8c camel-jbang (tui) - Add validation on save for Spring 
Boot properties
7c3eb36e4a8c is described below

commit 7c3eb36e4a8c2a8d2b45578b43840def30ce2909
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Aug 12 19:48:46 2026 +0200

    camel-jbang (tui) - Add validation on save for Spring Boot properties
    
    When saving application.properties, unknown Spring Boot property keys
    are now flagged alongside Camel property validation. Only properties
    within a known Spring Boot namespace (e.g. spring.datasource.*) are
    checked — custom app properties are silently ignored to avoid false
    positives.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/SourceTab.java     | 62 +++++++++++++++++-----
 1 file changed, 50 insertions(+), 12 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
index a12165d3d913..84322cf740f4 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
@@ -1820,22 +1820,60 @@ class SourceTab extends AbstractTab {
 
     private String validatePropertyLine(String line) {
         CamelCatalog catalog = getCatalog();
-        if (catalog == null) {
+        if (catalog != null) {
+            try {
+                ConfigurationPropertiesValidationResult result = 
catalog.validateConfigurationProperty(line);
+                if (result.isAccepted()) {
+                    if (!result.isSuccess()) {
+                        String msg = result.summaryErrorMessage(false);
+                        if (msg != null) {
+                            return msg.trim();
+                        }
+                    }
+                    return null;
+                }
+            } catch (Exception e) {
+                // ignore validation errors
+            }
+        }
+        // validate Spring Boot properties
+        return validateSpringBootPropertyLine(line);
+    }
+
+    private String validateSpringBootPropertyLine(String line) {
+        ensureSpringBootMetadataCache();
+        if (springBootOptionsCache == null || 
springBootOptionsCache.isEmpty()) {
             return null;
         }
-        try {
-            ConfigurationPropertiesValidationResult result = 
catalog.validateConfigurationProperty(line);
-            if (!result.isAccepted()) {
-                return null;
-            }
-            if (!result.isSuccess()) {
-                String msg = result.summaryErrorMessage(false);
-                if (msg != null) {
-                    return msg.trim();
+        String trimmed = line.trim();
+        int eq = trimmed.indexOf('=');
+        if (eq <= 0) {
+            return null;
+        }
+        String key = trimmed.substring(0, eq).trim();
+        // only validate keys that look like Spring Boot properties
+        if (key.startsWith("camel.") || key.startsWith("#") || 
key.startsWith("!")) {
+            return null;
+        }
+        // check if the key exists in Spring Boot metadata
+        if (!springBootOptionsCache.containsKey(key)) {
+            // check if it's a known prefix (partial key) — don't flag those
+            for (String known : springBootOptionsCache.keySet()) {
+                if (known.startsWith(key + ".")) {
+                    return null;
                 }
             }
-        } catch (Exception e) {
-            // ignore validation errors
+            // check if it belongs to a known Spring Boot group
+            boolean inSpringBootNamespace = false;
+            for (String group : springBootGroupsCache.keySet()) {
+                if (key.startsWith(group + ".")) {
+                    inSpringBootNamespace = true;
+                    break;
+                }
+            }
+            if (inSpringBootNamespace) {
+                return "Unknown Spring Boot property: " + key;
+            }
         }
         return null;
     }

Reply via email to