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 5766a64b8d00 CAMEL-25328: camel-yaml-dsl-validator - an error handler 
written as a route step says where it goes (#27348)
5766a64b8d00 is described below

commit 5766a64b8d00d3a63e925a63eda9a3d4c9052a62
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Oct 5 07:39:13 2026 +0200

    CAMEL-25328: camel-yaml-dsl-validator - an error handler written as a route 
step says where it goes (#27348)
    
    `- noErrorHandler: {}` as a step of the route was refused with "property
    'noErrorHandler' is not defined in the schema" and no hint: CAMEL-24881
    covers the wrong shapes under route: and errorHandler:, not a step. A row 
for
    an error handler kind as an unknown property of a step now adds: an error
    handler is not a step: write it on the route, next to from:, as
    errorHandler: {noErrorHandler: {}} (a top-level - errorHandler: item applies
    to every route).
    
    
    Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
    
    Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
---
 .../apache/camel/dsl/yaml/validator/SchemaHints.java  |  5 +++++
 .../yaml/validator/YamlValidatorPropertyHintTest.java | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java
index a8b2e96b09fe..4f4b97a2bd59 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java
@@ -312,6 +312,11 @@ final class SchemaHints {
                          + " key: errorHandler: {noErrorHandler: {}}, 
errorHandler: {deadLetterChannel: {deadLetterUri:"
                          + " \"direct:parked\"}}, errorHandler: 
{defaultErrorHandler: {redeliveryPolicy: {...}}}"
                          + " (a top-level - errorHandler: item applies to 
every route)"),
+            // - noErrorHandler: {} as a step of the route: the handler goes 
on the route, not among its steps (CAMEL-25328)
+            unknownProperty(".*/steps/\\d+", m -> 
ROUTE_ERROR_HANDLER_KINDS.contains(m.unknown()),
+                    m -> "an error handler is not a step: write it on the 
route, next to from:, as errorHandler: {"
+                         + m.unknown() + ": " + 
(m.unknown().equals("noErrorHandler") ? "{}" : "{...}")
+                         + "} (a top-level - errorHandler: item applies to 
every route)"),
             unknownProperty(".*/errorHandler", m -> m.unknown().equals("type") 
|| m.unknown().equals("errorHandlerType"),
                     m -> "errorHandler: has the kind of handler as its key, 
not a " + m.unknown() + " property:"
                          + " errorHandler: {noErrorHandler: {}}, 
{deadLetterChannel: {deadLetterUri: \"...\"}} or"
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/YamlValidatorPropertyHintTest.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/YamlValidatorPropertyHintTest.java
index d90380a8a37d..7def87e4ed95 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/YamlValidatorPropertyHintTest.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/test/java/org/apache/camel/dsl/yaml/validator/YamlValidatorPropertyHintTest.java
@@ -90,6 +90,25 @@ public class YamlValidatorPropertyHintTest {
         }
     }
 
+    /** CAMEL-25328: an error handler written as a step of the route says 
where it goes. */
+    @Test
+    public void testErrorHandlerAsAStepGetsTheRouteForm() throws Exception {
+        for (YamlValidator v : bothModes()) {
+            List<Error> errors = v.validate("""
+                    - route:
+                        id: payment-provider
+                        from:
+                          uri: direct:charge
+                          steps:
+                            - noErrorHandler: {}
+                            - log: "charged"
+                    """);
+            assertThat(errors).extracting(Error::getMessage)
+                    .anyMatch(m -> m.contains("noErrorHandler") && 
m.contains("an error handler is not a step")
+                            && m.contains("errorHandler: {noErrorHandler: 
{}}"));
+        }
+    }
+
     /** CAMEL-24888: the shapes the local model wrote on the HTTP rungs, each 
with the form to write. */
     @Test
     public void testHttpRungShapesGetTheForm() throws Exception {

Reply via email to