Repository: kestra-io/kestra
Issue: Inputs can have duplicated name
Labels: bug

### Expected Behavior

An error should be thrown when two inputs are defined with the same name (before execution).

### Actual Behaviour

Inputs can have duplicated name

### Steps To Reproduce

```yaml
id: a-flow
namespace: some.namespace
inputs:
  - name: first_input
    required: true
    type: STRING
  - name: first_input
    required: true
    type: INT
tasks:
  - id: taskOne
    type: io.kestra.core.tasks.log.Log
    message: "{{ inputs.first_input }}"
```

### Environment Information

- Kestra Version: 0.8.0-SNAPSHOT

### Example flow

_No response_

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/validations/ValidationFactory.java b/core/src/main/java/io/kestra/core/validations/ValidationFactory.java
index 7c54c83b65..21289099d4 100644
--- a/core/src/main/java/io/kestra/core/validations/ValidationFactory.java
+++ b/core/src/main/java/io/kestra/core/validations/ValidationFactory.java
@@ -123,21 +123,35 @@ ConstraintValidator<FlowValidation, Flow> flowValidation() {
             }
 
             List<String> violations = new ArrayList<>();
-            List<Task> allTasks = value.allTasksWithChilds();
 
-            // unique id
-            List<String> ids = allTasks
+            // task unique id
+            List<String> taskIds = value.allTasksWithChilds()
                 .stream()
                 .map(Task::getId)
-                .collect(Collectors.toList());
-
-            List<String> duplicates = ids
+                .toList();
+            List<String> taskDuplicates = taskIds
                 .stream()
                 .distinct()
-                .filter(entry -> Collections.frequency(ids, entry) > 1).collect(Collectors.toList());
+                .filter(entry -> Collections.frequency(taskIds, entry) > 1)
+                .toList();
+            if (taskDuplicates.size() > 0) {
+                violations.add("Duplicate task id with name [" + String.join(", ", taskDuplicates) + "]");
+            }
 
-            if (duplicates.size() > 0) {
-                violations.add("Duplicate task id with name [" + String.join(", ", duplicates) + "]");
+            // input unique name
+            if (value.getInputs() != null) {
+                List<String> inputNames = value.getInputs()
+                    .stream()
+                    .map(Input::getName)
+                    .toList();
+                List<String> inputDuplicates = inputNames
+                    .stream()
+                    .distinct()
+                    .filter(entry -> Collections.frequency(inputNames, entry) > 1)
+                    .toList();
+                if (inputDuplicates.size() > 0) {
+                    violations.add("Duplicate input with name [" + String.join(", ", inputDuplicates) + "]");
+                }
             }
 
             if (violations.size() > 0) {


Test patch:
diff --git a/core/src/test/java/io/kestra/core/models/flows/FlowTest.java b/core/src/test/java/io/kestra/core/models/flows/FlowTest.java
index 1935de5566..4eb7f1cbb9 100644
--- a/core/src/test/java/io/kestra/core/models/flows/FlowTest.java
+++ b/core/src/test/java/io/kestra/core/models/flows/FlowTest.java
@@ -39,6 +39,17 @@ void duplicate() {
         assertThat(validate.get().getMessage(), containsString("Duplicate task id with name [date]"));
     }
 
+    @Test
+    void duplicateInputs() {
+        Flow flow = this.parse("flows/invalids/duplicate-inputs.yaml");
+        Optional<ConstraintViolationException> validate = modelValidator.isValid(flow);
+
+        assertThat(validate.isPresent(), is(true));
+        assertThat(validate.get().getConstraintViolations().size(), is(1));
+
+        assertThat(validate.get().getMessage(), containsString("Duplicate input with name [first_input]"));
+    }
+
     @Test
     void duplicateParallel() {
         Flow flow = this.parse("flows/invalids/duplicate-parallel.yaml");
diff --git a/core/src/test/resources/flows/invalids/duplicate-inputs.yaml b/core/src/test/resources/flows/invalids/duplicate-inputs.yaml
new file mode 100644
index 0000000000..d2b57df6ce
--- /dev/null
+++ b/core/src/test/resources/flows/invalids/duplicate-inputs.yaml
@@ -0,0 +1,14 @@
+id: duplicate-inputs
+namespace: io.kestra.tests
+
+inputs:
+  - name: first_input
+    required: true
+    type: STRING
+  - name: first_input
+    required: true
+    type: STRING
+tasks:
+  - id: taskOne
+    type: io.kestra.core.tasks.log.Log
+    message: "{{ inputs.first_input }}"
\ No newline at end of file