Repository: kestra-io/kestra
Issue: Invalid yaml don't have any error message 
Labels: bug
frontend

```yaml
id: "valid"
namespace: "com.kestra.lde"
tasks:
  - id: "plan"
    type: "io.kestra.core.tasks.scripts.Bash"
    inputFiles:
      variables.tf: | 
        test
      variables.tf: | 
        test
    commands: 
      - ls 
```

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/serializers/YamlFlowParser.java b/core/src/main/java/io/kestra/core/serializers/YamlFlowParser.java
index c0eea39dec..3f2e4e4523 100644
--- a/core/src/main/java/io/kestra/core/serializers/YamlFlowParser.java
+++ b/core/src/main/java/io/kestra/core/serializers/YamlFlowParser.java
@@ -1,5 +1,6 @@
 package io.kestra.core.serializers;
 
+import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.InjectableValues;
@@ -13,19 +14,20 @@
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
 
+import javax.validation.ConstraintViolationException;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.util.Collections;
 import java.util.Set;
-import javax.validation.ConstraintViolationException;
 
 @Singleton
 public class YamlFlowParser {
     public static final String CONTEXT_FLOW_DIRECTORY = "flowDirectory";
 
     private static final ObjectMapper mapper = JacksonMapper.ofYaml()
+        .enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION)
         .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
         .registerModule(new SimpleModule("HandleBarDeserializer")
             .addDeserializer(String.class, new HandleBarDeserializer())


Test patch:
diff --git a/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java b/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java
index b1354e0916..2b5d36caa9 100644
--- a/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java
+++ b/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java
@@ -1,18 +1,20 @@
 package io.kestra.core.serializers;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import io.kestra.core.models.flows.Flow;
 import io.kestra.core.models.flows.Input;
 import io.kestra.core.models.flows.input.StringInput;
-import io.kestra.core.models.validations.ModelValidator;
-import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
-import org.junit.jupiter.api.Test;
-import io.kestra.core.models.flows.Flow;
 import io.kestra.core.models.tasks.Task;
 import io.kestra.core.models.tasks.retrys.Constant;
 import io.kestra.core.models.triggers.types.Schedule;
+import io.kestra.core.models.validations.ModelValidator;
 import io.kestra.core.tasks.debugs.Return;
 import io.kestra.core.utils.TestsUtils;
+import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
+import jakarta.inject.Inject;
+import org.junit.jupiter.api.Test;
 
+import javax.validation.ConstraintViolationException;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
@@ -24,10 +26,6 @@
 import java.util.ArrayList;
 import java.util.Optional;
 
-import jakarta.inject.Inject;
-
-import javax.validation.ConstraintViolationException;
-
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -241,6 +239,17 @@ void invalidParallel() {
         assertThat(new ArrayList<>(valid.get().getConstraintViolations()).stream().filter(r -> r.getMessage().contains("must not be empty")).count(), is(3L));
     }
 
+    @Test
+    void duplicateKey() {
+        ConstraintViolationException exception = assertThrows(
+            ConstraintViolationException.class,
+            () -> this.parse("flows/invalids/duplicate-key.yaml")
+        );
+
+        assertThat(exception.getConstraintViolations().size(), is(1));
+        assertThat(new ArrayList<>(exception.getConstraintViolations()).get(0).getMessage(), containsString("Duplicate field 'variables.tf'"));
+    }
+
     private Flow parse(String path) {
         URL resource = TestsUtils.class.getClassLoader().getResource(path);
         assert resource != null;
diff --git a/core/src/test/resources/flows/invalids/duplicate-key.yaml b/core/src/test/resources/flows/invalids/duplicate-key.yaml
new file mode 100644
index 0000000000..9889bcac57
--- /dev/null
+++ b/core/src/test/resources/flows/invalids/duplicate-key.yaml
@@ -0,0 +1,13 @@
+id: duplicate-key
+namespace: io.kestra.tests
+
+tasks:
+  - id: bad-task
+    type: "io.kestra.core.tasks.scripts.Bash"
+    inputFiles:
+      variables.tf: |
+        test
+      variables.tf: |
+        test
+    commands:
+      - ls
\ No newline at end of file