Repository: kestra-io/kestra (java)

Issue:
[UI] Show an error in the editor when a FILE-type input has a default value attached to it
### Expected Behavior

When a type file input is defined, it can not have a default value. An error should be thrown.

### Actual Behaviour

When a type file input is defined, it can have a default value.

### Steps To Reproduce

_No response_

### Environment Information

- Kestra Version: 0.8.0-SNAPSHOT

### Example flow

_No response_

Pull request description:
feat(core): validate that an input of type FILE didn't have any defaults
Fixes #1091

Example flow:
```yaml
id: bar-input-file
namespace: company.myteam

inputs:
  - id: file
    type: FILE
    defaults: something

tasks:
  - id: hello
    type: io.kestra.plugin.core.log.Log
    message: Hello World! 🚀
```

Result:
![image](https://github.com/kestra-io/kestra/assets/1819009/98573d87-786f-4aeb-a0bb-6a8f91ef0848)


Patch:
diff --git a/core/src/main/java/io/kestra/core/models/flows/input/FileInput.java b/core/src/main/java/io/kestra/core/models/flows/input/FileInput.java
index 76753ec16..78d2f1e17 100644
--- a/core/src/main/java/io/kestra/core/models/flows/input/FileInput.java
+++ b/core/src/main/java/io/kestra/core/models/flows/input/FileInput.java
@@ -1,6 +1,7 @@
 package io.kestra.core.models.flows.input;
 
 import io.kestra.core.models.flows.Input;
+import io.kestra.core.validations.FileInputValidation;
 import jakarta.validation.ConstraintViolationException;
 import lombok.Builder;
 import lombok.Getter;
@@ -12,6 +13,7 @@ import java.net.URI;
 @SuperBuilder
 @Getter
 @NoArgsConstructor
+@FileInputValidation
 public class FileInput extends Input<URI> {
     @Builder.Default
     public String extension = ".upl";
diff --git a/core/src/main/java/io/kestra/core/validations/FileInputValidation.java b/core/src/main/java/io/kestra/core/validations/FileInputValidation.java
new file mode 100644
index 000000000..689c7937e
--- /dev/null
+++ b/core/src/main/java/io/kestra/core/validations/FileInputValidation.java
@@ -0,0 +1,16 @@
+package io.kestra.core.validations;
+
+import io.kestra.core.validations.validator.FileInputValidator;
+import jakarta.validation.Constraint;
+import jakarta.validation.Payload;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Constraint(validatedBy = FileInputValidator.class)
+public @interface FileInputValidation {
+    String message() default "invalid file input";
+    Class<?>[] groups() default {};
+    Class<? extends Payload>[] payload() default {};
+}
diff --git a/core/src/main/java/io/kestra/core/validations/validator/FileInputValidator.java b/core/src/main/java/io/kestra/core/validations/validator/FileInputValidator.java
new file mode 100644
index 000000000..d999fdcb9
--- /dev/null
+++ b/core/src/main/java/io/kestra/core/validations/validator/FileInputValidator.java
@@ -0,0 +1,31 @@
+package io.kestra.core.validations.validator;
+
+import io.kestra.core.models.flows.input.FileInput;
+import io.kestra.core.validations.FileInputValidation;
+import io.micronaut.core.annotation.AnnotationValue;
+import io.micronaut.core.annotation.Introspected;
+import io.micronaut.core.annotation.NonNull;
+import io.micronaut.core.annotation.Nullable;
+import io.micronaut.validation.validator.constraints.ConstraintValidator;
+import io.micronaut.validation.validator.constraints.ConstraintValidatorContext;
+import jakarta.inject.Singleton;
+
+@Singleton
+@Introspected
+public class FileInputValidator implements ConstraintValidator<FileInputValidation, FileInput> {
+    @Override
+    public boolean isValid(@Nullable FileInput value, @NonNull AnnotationValue<FileInputValidation> annotationMetadata, @NonNull ConstraintValidatorContext context) {
+        if (value == null) {
+            return true; // nulls are allowed according to spec
+        }
+
+        if (value.getDefaults() != null) {
+            context.disableDefaultConstraintViolation();
+            context.buildConstraintViolationWithTemplate("no `defaults` can be set for inputs of type 'FILE'")
+                .addConstraintViolation();
+            return false;
+        }
+
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/ui/src/utils/axios.js b/ui/src/utils/axios.js
index 217862002..28f007c6d 100644
--- a/ui/src/utils/axios.js
+++ b/ui/src/utils/axios.js
@@ -123,7 +123,6 @@ export default (callback, store, router) => {
             }
 
             if (errorResponse.response.data) {
-                console.log("heret", errorResponse.response.data)
                 store.dispatch("core/showMessage", {
                     response: errorResponse.response,
                     content: errorResponse.response.data,


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 9e6c3b9ff..f63755034 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
@@ -142,6 +142,18 @@ class FlowTest {
         assertThat(all.size(), is(3));
     }
 
+    @Test
+    void inputValidation() {
+        Flow flow = this.parse("flows/invalids/inputs-validation.yaml");
+        Optional<ConstraintViolationException> validate = modelValidator.isValid(flow);
+
+        assertThat(validate.isPresent(), is(true));
+        assertThat(validate.get().getConstraintViolations().size(), is(2));
+
+        assertThat(validate.get().getMessage(), containsString("inputs[0]: no `defaults` can be set for inputs of type 'FILE'"));
+        assertThat(validate.get().getMessage(), containsString("inputs[1]: `itemType` cannot be `ARRAY"));
+    }
+
     private Flow parse(String path) {
         URL resource = TestsUtils.class.getClassLoader().getResource(path);
         assert resource != null;
diff --git a/core/src/test/resources/flows/invalids/inputs-validation.yaml b/core/src/test/resources/flows/invalids/inputs-validation.yaml
new file mode 100644
index 000000000..8fb108c95
--- /dev/null
+++ b/core/src/test/resources/flows/invalids/inputs-validation.yaml
@@ -0,0 +1,15 @@
+id: inputs-validations
+namespace: io.kestra.tests
+
+inputs:
+  - id: file
+    type: FILE
+    defaults: something
+  - id: array
+    type: ARRAY
+    itemType: ARRAY
+
+tasks:
+  - id: hello
+    type: io.kestra.plugin.core.log.Log
+    message: Hello World! 🚀
\ No newline at end of file