You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ld...@apache.org on 2026/10/08 09:06:31 UTC
(camel) 06/08: CAMEL-25382: Address semantic validation review nits
This is an automated email from the ASF dual-hosted git repository.
luigidemasi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 03d215da95cf3119035e0a58c77195e12b6394f4
Author: Luigi De Masi <ld...@redhat.com>
AuthorDate: Wed Oct 7 20:10:37 2026 +0200
CAMEL-25382: Address semantic validation review nits
Recognize the stable missing-dependency phrase in JBang diagnostics instead
of requiring the entire error message. Cover changed surrounding wording
through the source validator while preserving malformed-argument checks.
Explain why the concurrent registry test returns no lazy plugin: it allows
SemanticEvaluations.get() to create and register the instance under test.
Co-authored-by: Codex <no...@openai.com>
Signed-off-by: Luigi De Masi <ld...@redhat.com>
---
.../camel/semantic/SemanticInitializationTest.java | 1 +
.../dsl/jbang/core/commands/ai/SimpleChecks.java | 2 +-
.../commands/ai/SourceValidatorSimpleTest.java | 23 +++++++++++++++++++++-
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/components/camel-ai/camel-semantic/src/test/java/org/apache/camel/semantic/SemanticInitializationTest.java b/components/camel-ai/camel-semantic/src/test/java/org/apache/camel/semantic/SemanticInitializationTest.java
index 12ccaabcd399..ef47233e353f 100644
--- a/components/camel-ai/camel-semantic/src/test/java/org/apache/camel/semantic/SemanticInitializationTest.java
+++ b/components/camel-ai/camel-semantic/src/test/java/org/apache/camel/semantic/SemanticInitializationTest.java
@@ -91,6 +91,7 @@ class SemanticInitializationTest {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
}
+ // Leave the plugin absent so get() creates and registers it after this lookup is released.
return null;
});
var creation = callers.submit(() -> SemanticEvaluations.get(creating));
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/SimpleChecks.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/SimpleChecks.java
index 5d71ae876aab..77425ddd647c 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/SimpleChecks.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/SimpleChecks.java
@@ -223,7 +223,7 @@ final class SimpleChecks {
static boolean isMissingDependency(String error) {
return error.startsWith("No language could be found for:")
- || error.equals("The semantic function requires camel-semantic on the classpath")
+ || error.contains("requires camel-semantic")
|| error.startsWith("No " + SimpleLanguageFunctionFactory.FACTORY + "/")
&& error.contains("service could be found in the classpath");
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorSimpleTest.java b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorSimpleTest.java
index 13a0917d8020..9a16a68d2368 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorSimpleTest.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorSimpleTest.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.apache.camel.catalog.CamelCatalog;
import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.catalog.LanguageValidationResult;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -255,10 +256,30 @@ class SourceValidatorSimpleTest {
assertThat(msgs).isEmpty();
}
+ @Test
+ void semanticDependencyDetectionToleratesSurroundingDiagnosticChanges() {
+ CamelCatalog changedDiagnostic = new DefaultCamelCatalog() {
+ @Override
+ public LanguageValidationResult validateLanguageExpression(ClassLoader classLoader, String language, String text) {
+ LanguageValidationResult result = new LanguageValidationResult(text);
+ result.setError("Semantic evaluation requires camel-semantic; add the dependency to use this function");
+ return result;
+ }
+ };
+ List<String> msgs = SourceValidator.validateYamlSimple("""
+ - from:
+ uri: direct:start
+ steps:
+ - setBody:
+ simple: "${semantic('department')}"
+ """, changedDiagnostic);
+ assertThat(msgs).isEmpty();
+ }
+
@Test
void semanticExpressionsAndPredicatesDoNotRequireTheRuntimeDependency() {
assertThat(catalog.validateLanguageExpression(null, "simple", "${semantic('department')}").getShortError())
- .isEqualTo("The semantic function requires camel-semantic on the classpath");
+ .contains("requires camel-semantic");
List<String> msgs = SourceValidator.validateYamlSimple("""
- from:
uri: direct:start