Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow's untyped input defaults can lead to runtime errors #5590

Open
yuri1969 opened this issue Oct 22, 2024 · 3 comments · May be fixed by #5604
Open

Flow's untyped input defaults can lead to runtime errors #5590

yuri1969 opened this issue Oct 22, 2024 · 3 comments · May be fixed by #5604
Assignees
Labels
area/backend Needs backend code changes bug Something isn't working kind/customer-request Requested by one or more customers

Comments

@yuri1969
Copy link
Contributor

Describe the issue

TL;DR flow's input defaults should be correctly typed.


Currently the flow's input defaults field is not typed - it is a simple Object. This can lead to unexpected runtime errors in situations when a wrongly typed default is effectively applied and a validator is defined.

For example, a validated STRING input with defaults being an integer fails since the validator can not be applied on an integer:

id: badDefaults
namespace: io.kestra.tests

inputs:
  - id: intDefaultsInStrInput
    type: STRING
    validator: '\d+'
    defaults: 100
    required: false

tasks:
  - id: date
    type: io.kestra.plugin.core.debug.Return
    format: "{{taskrun.startDate}}"

Execute the flow above using the API and omit the flow input completely - the execution fails on validation.


The same behavior can be demonstrated by the following unit test: mismatchedDefaults.patch


It feels like this issue should be easily solved by switching the Inputs defaults attribute type from Object to the generic type T - Input.java L81. It enables JSON Schema generation for the defaults.

However, it breaks at least the TIME input a bit - JSON Schema's time requires timezone. Also the value itself is not validated.

Environment

  • Kestra Version: v0.20-SNAPSHOT
  • Operating System (OS/Docker/Kubernetes):
  • Java Version (if you don't run kestra in Docker): 21 Temurin
@yuri1969 yuri1969 added the bug Something isn't working label Oct 22, 2024
@loicmathieu loicmathieu added the area/backend Needs backend code changes label Oct 22, 2024
@Malaydewangan09
Copy link
Contributor

Hey @loicmathieu
Can I pick this up?
Thanks!

@loicmathieu
Copy link
Member

@Malaydewangan09 yes, I assigned you to the issue.

@Malaydewangan09
Copy link
Contributor

@loicmathieu Thanks!

@Ben8t Ben8t added the kind/customer-request Requested by one or more customers label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend Needs backend code changes bug Something isn't working kind/customer-request Requested by one or more customers
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

4 participants