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

The curl command displayed in the Execute modal fills default values incorrectly for inputs of type FILE, DURATION, TIME and DATE #4661

Closed
Tracked by #4656
anna-geller opened this issue Aug 14, 2024 · 2 comments · Fixed by #4696
Assignees
Labels
area/frontend Needs frontend code changes bug Something isn't working

Comments

@anna-geller
Copy link
Member

anna-geller commented Aug 14, 2024

Note: all of the below was tested on kestra 0.18.1, not on develop.

There are several issues with the current curl command.

Consider this example:

id: myflow
namespace: company.team

inputs:
  - id: user
    type: STRING
    required: false
    defaults: Rick Astley

  - id: int
    type: INT
    defaults: 100

  - id: list_of_int
    type: ARRAY
    itemType: INT
    defaults: [1, 2, 3]

  - id: bool
    type: BOOLEAN
    defaults: true

  - id: float
    type: FLOAT
    defaults: 42.42

  - id: select
    type: SELECT 
    defaults: VALUE_1
    values:
      - VALUE_1
      - VALUE_2
      - VALUE_3

  - id: multiselect
    type: MULTISELECT 
    defaults: 
      - VALUE_1
      - VALUE_2
    options:
      - VALUE_1
      - VALUE_2
      - VALUE_3

  - id: dt
    type: DATETIME
    defaults: "2024-08-09T14:19:00Z"

  - id: json
    type: JSON
    defaults: |-
      [{"name": "kestra", "rating": "best in class"}]

  - id: secret
    type: SECRET
    defaults: test

  - id: file
    type: FILE
    required: false

tasks:
  - id: hello
    type: io.kestra.plugin.core.log.Log
    message: Hello {{ inputs.user }}

  - id: get
    type: io.kestra.plugin.core.output.OutputValues
    values: 
      inputs: "{{ inputs }}"

Missing FILE-type input

The curl command displayed in the UI will not include the FILE-type input. Given that this is one of the most difficult to use property (with no option to set defaults), we should provide a way to use a sample value. I'd recommend to add a download command first to download a sample file and then pass it within the command:

curl -O https://huggingface.co/datasets/kestra/datasets/resolve/main/json/kestra.json && curl -v -X POST -H 'Content-Type: multipart/form-data' -F 'user=Rick Astley' -F 'int=100' -F 'list_of_int=[1,2,3]' -F 'bool=true' -F 'float=42.42' -F 'select=VALUE_1' -F 'multiselect=["VALUE_1","VALUE_2"]' -F 'dt=2024-08-09T14:19:00.000Z' -F 'json=[{"name": "kestra", "rating": "best in class"}]' -F 'secret=test' -F 'files=@kestra.json;filename=file' 'http://localhost:8080/api/v1/executions/company.team/myflow'

Temporal properties are not handled well

Now extend this flow with the following temporal inputs:

  - id: date
    type: DATE
    defaults: "2024-10-25"
    description: Illegal state as curl shows this as datetime -F 'date=2024-10-24T22:00:00.000Z'

  - id: time
    type: TIME
    defaults: "12:45:00"
    description: Illegal state as curl shows this as -F 'time=Wed Aug 14 2024 12:45:00 GMT+0200'

  - id: duration
    type: DURATION
    defaults: "PT1H"
    description: Illegal state as curl shows this as -F 'duration=Wed Aug 14 2024 01:00:00 GMT+0200'

All of those input types DATE, TIME and DURATION will generate a wrong default value in the curl command. This is the command generated from the UI:

curl -v -X POST -H 'Content-Type: multipart/form-data' -F 'user=Rick Astley' -F 'int=100' -F 'list_of_int=[1,2,3]' -F 'bool=true' -F 'float=42.42' -F 'select=VALUE_1' -F 'multiselect=["VALUE_1","VALUE_2"]' -F 'dt=2024-08-09T14:19:00.000Z' -F 'json=[{"name": "kestra", "rating": "best in class"}]' -F 'date=2024-10-24T22:00:00.000Z' -F 'time=Wed Aug 14 2024 12:45:00 GMT+0200' -F 'duration=Wed Aug 14 2024 01:00:00 GMT+0200' -F 'secret=******' 'http://localhost:8080/api/v1/executions/company.team/myflow'

TIME and DURATION got interpreted as Wed Aug 14... -- illegal format.

The correct command should be:

curl -v -X POST -H 'Content-Type: multipart/form-data' -F 'user=Rick Astley' -F 'int=100' -F 'list_of_int=[1,2,3]' -F 'bool=true' -F 'float=42.42' -F 'select=VALUE_1' -F 'multiselect=["VALUE_1","VALUE_2"]' -F 'dt=2024-08-09T14:19:00.000Z' -F 'json=[{"name": "kestra", "rating": "best in class"}]' -F 'secret=test' -F 'files=@kestra.json;filename=file' -F 'duration=PT1H' -F 'date=2024-10-25'  -F 'time=12:45:00' 'http://localhost:8080/api/v1/executions/company.team/myflow'

Environment

  • Kestra Version:
  • Operating System (OS/Docker/Kubernetes):
  • Java Version (if you don't run kestra in Docker):
@anna-geller anna-geller added bug Something isn't working area/frontend Needs frontend code changes labels Aug 14, 2024
@MilosPaunovic
Copy link
Member

Hey @yuri1969, as you're the author of initial cURL functionalities (#4308), would you be interested in trying to tackle this one, as well?

@yuri1969
Copy link
Contributor

@MilosPaunovic Yea, no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Needs frontend code changes bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants