Skip to content

fix(flows): fix OpenAPI spec generation for FlowController endpoints#15482

Merged
nkwiatkowski merged 3 commits intodevelopfrom
fix/openapi-flow-endpoints-generation
Apr 21, 2026
Merged

fix(flows): fix OpenAPI spec generation for FlowController endpoints#15482
nkwiatkowski merged 3 commits intodevelopfrom
fix/openapi-flow-endpoints-generation

Conversation

@AcevedoR
Copy link
Copy Markdown
Contributor

@AcevedoR AcevedoR commented Apr 9, 2026

Summary

  • The Micronaut OpenAPI annotation processor was skipping all FlowController endpoints mapped to {namespace}/{id} (GET, PUT, DELETE), generating an empty path {} in openapi.yml
  • Root cause: processing FlowWithSourceFlow/TaskAbstractRetry → concrete subtypes (Constant, Exponential, Random) triggered a PostponeToNextRoundException because Micronaut constraint validators on those subtypes are processed in the same annotation processing round, making their metadata unavailable to the OpenAPI processor
  • 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; add class-level @Schema documentation to the concrete retry subtypes

Test plan

  • Run ./gradlew generateOpenapiSpec --rerun-tasks and verify no PostponeToNextRoundException warning in the output
  • Verify /api/v1/{tenant}/flows/{namespace}/{id} in openapi.yml contains get, put, and delete operations (was previously {})
  • Verify no existing tests are broken: ./gradlew :webserver:test

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

🐋 Docker image

ghcr.io/kestra-io/kestra-pr:15482
docker run --pull=always --rm -it -p 8080:8080 --user=root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp ghcr.io/kestra-io/kestra-pr:15482 server local

🧪 Java Unit Tests

TestsPassed ✅Skipped ⚠️FailedTime ⏱
Java Tests Report5197 ran5175 ✅22 ⚠️0 ❌51m 21s 329ms

@AcevedoR AcevedoR force-pushed the fix/openapi-flow-endpoints-generation branch from 5578165 to 92f4dc8 Compare April 9, 2026 18:10
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Tests report quick summary:

success ✅ > tests: 5198, success: 5175, skipped: 22, failed: 1

unfold for details
Project Status Success Skipped Failed
cli success ✅ 47 0 0
core success ✅ 2506 0 0
executor success ✅ 39 0 0
jdbc success ✅ 11 0 0
jdbc-h2 success ✅ 610 0 0
jdbc-mysql success ✅ 602 0 0
jdbc-postgres success ✅ 604 0 0
processor success ✅ 7 0 0
queue success ✅ 31 0 0
runner-memory success ✅ 1 0 0
scheduler success ✅ 71 0 0
script success ✅ 35 0 0
storage-local success ✅ 64 0 0
tests success ✅ 2 0 0
webserver success ✅ 428 0 0
worker success ✅ 52 0 0
worker-controller success ✅ 87 0 0

Develocity build scan: https://develocity.kestra.io/s/uow56k3irxbbk

Copy link
Copy Markdown
Member

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is a bit disapointing but if there are no other way around, let's do that.

Did you check autocompletion? It may no longuer work for retry which would not be very convenient.

Comment thread core/src/main/java/io/kestra/core/models/flows/Flow.java
@AcevedoR AcevedoR force-pushed the fix/openapi-flow-endpoints-generation branch 2 times, most recently from d0ce4e2 to 4c57b50 Compare April 17, 2026 14:51
@AcevedoR AcevedoR force-pushed the fix/openapi-flow-endpoints-generation branch 2 times, most recently from 87f6651 to bac8151 Compare April 20, 2026 16:01
AcevedoR and others added 3 commits April 21, 2026 15:03
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.
…orkaround

The @Schema(implementation = Object.class) on Task/Flow retry fields
fixes the Micronaut OpenAPI processor crash but also caused Swagger2Module
to override the field type at runtime, hiding retry subtypes from plugin
schemas.

Override Swagger2Module.resolveTargetTypeOverrides() to skip the
Object.class override only for AbstractRetry fields. Replace custom
@constraint validators on retry subtypes with @AssertTrue methods to
eliminate the Micronaut bean references that caused the processor crash.
@nkwiatkowski nkwiatkowski force-pushed the fix/openapi-flow-endpoints-generation branch from d4a8fee to a90f36d Compare April 21, 2026 13:06
@nkwiatkowski nkwiatkowski enabled auto-merge (squash) April 21, 2026 13:31
@nkwiatkowski nkwiatkowski merged commit a4232cc into develop Apr 21, 2026
11 of 12 checks passed
@nkwiatkowski nkwiatkowski deleted the fix/openapi-flow-endpoints-generation branch April 21, 2026 14:27
@github-project-automation github-project-automation Bot moved this from To review to Done in Pull Requests Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

openapi spec generation fails on Flows

3 participants