kestra-io / kestra

:zap: Workflow Automation Platform. Orchestrate & Schedule code in any language, run anywhere, 500+ plugins. Alternative to Zapier, Rundeck, Camunda, Airflow...
https://kestra.io
Apache License 2.0
12.94k stars 1.13k forks source link

Debug Outputs has incorrect expression when opened #5884

Open wrussell1999 opened 3 days ago

wrussell1999 commented 3 days ago

Describe the issue

When first opening the Outputs tab and no outputs are selected, Debug Outputs shows up with {{ outputs. }} which is invalid. It should instead say {{ outputs }}. Seems to do it on any flow you run because the first output is not selected correctly.

Screenshot 2024-11-12 at 12 29 14

Example Flow that generated this behaviour:

id: myflow
namespace: company.team

tasks:
  - id: hello
    type: io.kestra.plugin.core.log.Log
    message: Hello World! 🚀

Another:

id: deploy_if_true
namespace: company.team

inputs:
  - id: deploy
    type: BOOLEAN
    defaults: false

tasks:
  - id: code
    type: io.kestra.plugin.scripts.python.Script
    containerImage: ghcr.io/kestra-io/pydata:latest
    beforeCommands:
      - pip install kestra
    outputFiles:
      - processed_orders.csv
    script: |
      from kestra import Kestra
      import pandas as pd

      df = pd.read_csv('https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv')
      df['order_category'] = pd.cut(df['total'],
                                    bins=[0, 50, 150, float('inf')],
                                    labels=['Small', 'Medium', 'Large'])
      df.to_csv('processed_orders.csv')

      category_counts = df['order_category'].value_counts()
      outputs = {
                  "Small": int(category_counts.get('Small', 0)), 
                  "Medium": int(category_counts.get('Medium', 0)),
                  "Large": int(category_counts.get('Large', 0))
                }
      Kestra.outputs(outputs)

  - id: if
    type: io.kestra.plugin.core.flow.If
    condition: "{{ inputs.deploy == true }}"
    then:
      - id: s3_upload_discounts
        type: io.kestra.plugin.aws.s3.Upload
        region: eu-west-2
        bucket: oss-example
        key: "processed_orders.csv"
        from: "{{ outputs.code.outputFiles['processed_orders.csv']}}"
        accessKeyId: "{{ kv('AWS_ACCESS_KEY_ID') }}"
        secretKeyId: "{{ kv('AWS_SECRET_KEY_ID') }}"

Environment

5AIPAVAN commented 3 days ago

i would like to do this :-) please assign this to me

anna-geller commented 7 hours ago

The first output is expanded by default — that's expected. What's unexpected is that the expression is showing only outputs. instead of full outputs expression outputs.mytask.outputName image

Seems like regression introduced in PR to https://github.com/kestra-io/kestra/issues/5523

Reproducer flow:

id: get_data
namespace: company.team

inputs:
  - id: data
    displayName: Select Data to Download
    type: SELECT
    values:
      - customers
      - employees
      - products
      - stores
      - suppliers
    defaults: customers

tasks:
  - id: extract
    type: io.kestra.plugin.core.http.Download
    uri: https://huggingface.co/datasets/kestra/datasets/resolve/main/ion/{{ inputs.data }}.ion  

outputs:
  - id: data
    type: FILE
    value: "{{ outputs.extract.uri }}"