Repository: kestra-io/kestra
Issue: Raise an error in the editor when both `cron` and `interval` properties are defined in a `Schedule` trigger
Labels: bug

### Feature description

## Problem

When a trigger is defined using both CRON and interval as follows:

```yaml
triggers:
  - id: everyMinute
    type: io.kestra.core.models.triggers.types.Schedule
    cron: "*/1 * * * *"
    interval: "PT1M"
```

it results in no scheduled executions according to user report: https://kestra-io.slack.com/archives/C03FQKXRK3K/p1693486310182389 

## Possible resolution

Display a warning, or even better, raise an error within the editor if both properties are defined at the same time.

Additionally, it's worth introducing an extra logic to handle it directly within the `Schedule` trigger itself.

Issue comments:
I agree we should have a validation rule for that and display an error.
I think we should more prevent to set the value (maybe with a simple setter that thrown an exception) that prevent all usage everywhere
I have an old plan to break the dependency of the Schedule task to the PollingTrigger interface because it's 2 different things. This would remove the useless interval field that should not be set on this task.

So things can be done properly by refactoring and breaking this dependency ... or as a temporal workaround, we can add a setter that throws and see how we can prevent using it in the yaml schema. 
We discuss it this morning and will implement a workaround so that setting interval is not possible on a Schedule trigger (raises an error).

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java b/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java
index efdd8ea8a3..2552436f3d 100644
--- a/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java
+++ b/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java
@@ -21,6 +21,7 @@
 import io.kestra.core.runners.RunnerUtils;
 import io.kestra.core.services.ConditionService;
 import io.kestra.core.validations.CronExpression;
+import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.*;
 import lombok.experimental.SuperBuilder;
@@ -35,6 +36,7 @@
 import java.util.Optional;
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Null;
 
 @SuperBuilder
 @ToString
@@ -143,7 +145,9 @@ public class Schedule extends AbstractTrigger implements PollingTriggerInterface
     @PluginProperty
     private ScheduleBackfill backfill;
 
+    @Schema(hidden = true)
     @Builder.Default
+    @Null
     private final Duration interval = null;
 
     @Valid


Test patch:
diff --git a/core/src/test/java/io/kestra/core/validations/ScheduleTest.java b/core/src/test/java/io/kestra/core/validations/ScheduleTest.java
index 9759d3d281..d2370afeed 100644
--- a/core/src/test/java/io/kestra/core/validations/ScheduleTest.java
+++ b/core/src/test/java/io/kestra/core/validations/ScheduleTest.java
@@ -33,4 +33,19 @@ void cronValidation()  {
         assertThat(modelValidator.isValid(build).isPresent(), is(true));
         assertThat(modelValidator.isValid(build).get().getMessage(), containsString("backfill and lateMaximumDelay are incompatible options"));
     }
+
+    @Test
+    void intervalValidation() {
+        Schedule build = Schedule.builder()
+            .id(IdUtils.create())
+            .type(Schedule.class.getName())
+            .cron("* * * * *")
+            .interval(Duration.ofSeconds(5))
+            .build();
+
+
+        assertThat(modelValidator.isValid(build).isPresent(), is(true));
+        assertThat(modelValidator.isValid(build).get().getMessage(), containsString("interval: must be null"));
+
+    }
 }