Skip to content

Commit 87f6651

Browse files
committed
fix(flows): fix OpenAPI spec generation for FlowController endpoints
The Micronaut OpenAPI annotation processor was silently skipping all FlowController endpoints mapped to `{namespace}/{id}` (GET, PUT, DELETE) because processing `FlowWithSource` → `Flow`/`Task` → `AbstractRetry` triggered a `PostponeToNextRoundException` on the concrete retry subtypes (Constant, Exponential, Random). This exception occurs because the Micronaut constraint validators on those subtypes are processed in the same annotation processing round, making their metadata unavailable when the OpenAPI processor tries to introspect them. Fix: annotate the `retry` field in both `Flow` and `Task` with `@Schema(implementation = Object.class)` to prevent the processor from following the `@JsonSubTypes` chain on `AbstractRetry`. Also add class-level `@Schema` documentation to the concrete retry subtypes.
1 parent 39c3774 commit 87f6651

6 files changed

Lines changed: 1531 additions & 59 deletions

File tree

core/src/main/java/io/kestra/core/models/flows/Flow.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ public List<Task> getFinally() {
103103
@Valid
104104
List<Output> outputs;
105105

106+
// implementation = Object.class prevents the Micronaut OpenAPI annotation processor from following
107+
// the @JsonSubTypes on AbstractRetry, which causes a PostponeToNextRoundException at compile time
108+
// due to the Micronaut constraint validators on the concrete retry subtypes (Constant, Exponential, Random).
109+
@Schema(
110+
title = "Retry",
111+
description = "Retry policy applied when the flow fails.",
112+
implementation = Object.class
113+
)
106114
@Valid
107115
AbstractRetry retry;
108116

core/src/main/java/io/kestra/core/models/tasks/Task.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.kestra.core.runners.RunContext;
1919
import io.kestra.plugin.core.flow.WorkingDirectory;
2020

21+
import io.swagger.v3.oas.annotations.media.Schema;
2122
import jakarta.annotation.Nullable;
2223
import jakarta.validation.Valid;
2324
import jakarta.validation.constraints.Size;
@@ -45,6 +46,10 @@ abstract public class Task implements TaskInterface {
4546
@PluginProperty(hidden = true, group = "advanced")
4647
private String description;
4748

49+
// implementation = Object.class prevents the Micronaut OpenAPI annotation processor from following
50+
// the @JsonSubTypes on AbstractRetry, which causes a PostponeToNextRoundException at compile time
51+
// due to the Micronaut constraint validators on the concrete retry subtypes (Constant, Exponential, Random).
52+
@Schema(title = "Retry", description = "Retry policy applied when the task fails.", implementation = Object.class)
4853
@Valid
4954
@PluginProperty(hidden = true, group = "reliability")
5055
protected AbstractRetry retry;

core/src/main/java/io/kestra/core/models/tasks/retrys/Constant.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import io.kestra.core.validations.ConstantRetryValidation;
99

1010
import dev.failsafe.RetryPolicyBuilder;
11+
import io.swagger.v3.oas.annotations.media.Schema;
1112
import jakarta.validation.constraints.NotNull;
1213
import lombok.Builder;
1314
import lombok.Getter;
@@ -18,6 +19,7 @@
1819
@Getter
1920
@NoArgsConstructor
2021
@ConstantRetryValidation
22+
@Schema(title = "Constant retry", description = "Retry with a fixed delay between attempts.")
2123
public class Constant extends AbstractRetry {
2224
@NotNull
2325
@JsonInclude

core/src/main/java/io/kestra/core/models/tasks/retrys/Exponential.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.kestra.core.validations.ExponentialRetryValidation;
1010

1111
import dev.failsafe.RetryPolicyBuilder;
12+
import io.swagger.v3.oas.annotations.media.Schema;
1213
import jakarta.validation.constraints.NotNull;
1314
import lombok.Builder;
1415
import lombok.Getter;
@@ -19,6 +20,7 @@
1920
@Getter
2021
@NoArgsConstructor
2122
@ExponentialRetryValidation
23+
@Schema(title = "Exponential retry", description = "Retry with exponentially increasing delays between attempts.")
2224
public class Exponential extends AbstractRetry {
2325
@NotNull
2426
@JsonInclude

core/src/main/java/io/kestra/core/models/tasks/retrys/Random.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.kestra.core.validations.RandomRetryValidation;
1010

1111
import dev.failsafe.RetryPolicyBuilder;
12+
import io.swagger.v3.oas.annotations.media.Schema;
1213
import jakarta.validation.constraints.NotNull;
1314
import lombok.Builder;
1415
import lombok.Getter;
@@ -19,6 +20,7 @@
1920
@Getter
2021
@NoArgsConstructor
2122
@RandomRetryValidation
23+
@Schema(title = "Random retry", description = "Retry with a random delay within a configurable range between attempts.")
2224
public class Random extends AbstractRetry {
2325
@NotNull
2426
@JsonInclude

0 commit comments

Comments
 (0)