argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
14.62k stars 3.13k forks source link

`outputs.result` not working with jsonpath #10076

Open Digtiq opened 1 year ago

Digtiq commented 1 year ago

Pre-requisites

What happened/what you expected to happen?

hello, I have already tried many things but am in despair. Simple jsonpath doesn't work if I want to use the output from the step before. then the {{}} are just ignored and test:{{=jsonpath(tasks.dummy0.outputs.result, '$.test')}} is output which I think is a bug.

if i use the myjson parameter then everything works correctly.

Version

3.3.8

Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.

spec:
  templates:
    - name: main
      dag:
        tasks:
          - name: dummy0

            inline:
              container:
                image: docker/whalesay:latest
                command:
                  - sh
                  - '-c'
                args:
                  - echo "{{workflow.parameters.myjson}}"

          - name: dummy
            depends: "dummy0"

            arguments:
              parameters:
                - name: json
                  value: "{{tasks.dummy0.outputs.result}}"

            inline:
              inputs:
                parameters:
                  - name: json
              container:
                image: docker/whalesay:latest
                command:
                  - sh
                  - '-c'
                args:
                  #- echo 'test:{{=jsonpath(workflow.parameters.myjson, '$.test')}}' # working
                  - echo 'test:{{=jsonpath(tasks.dummy0.outputs.result, '$.test')}}' # not working

  entrypoint: main
  arguments:
    parameters:
      - name: myjson
        value: >-
          {"test": "0"}

Logs from the workflow controller

my-test-pkdgf--910287825: time="2022-11-19T11:30:43.113Z" level=info msg="capturing logs" argo=true
my-test-pkdgf--910287825: {test: 0}
my-test-pkdgf--910287825: time="2022-11-19T11:30:44.127Z" level=info msg="sub-process exited" argo=true error="<nil>"
my-test-pkdgf--1925477307: test:0

Logs from in your workflow's wait container

my-test2-frgg8--3934791511: test:{{=jsonpath(tasks.dummy0.outputs.result, $.test)}}
juliev0 commented 1 year ago

can you see if this is working on latest (3.4.3)?

Digtiq commented 1 year ago

same problem output is:

test:{{=jsonpath(tasks.dummy0.outputs.result, $.test)}}
juliev0 commented 1 year ago

okay, thanks for checking!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions.

cbandy commented 1 year ago

inline is a Container Template. Should arg be the following?

- echo 'test:{{=jsonpath(input.parameters.json, '$.test')}}'
neWs1587 commented 1 year ago

same problem!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions.

agilgur5 commented 9 months ago

We may want to retry this since https://github.com/argoproj/pkg/pull/486 / #11704 updated to a newer and more comprehensive JSONPath library. That was released in 3.5.0-rc2

agilgur5 commented 9 months ago

Oh, wait a minute.

                  #- echo 'test:{{=jsonpath(workflow.parameters.myjson, '$.test')}}' # working
                  - echo 'test:{{=jsonpath(tasks.dummy0.outputs.result, '$.test')}}' # not working

That might be because tasks.dummy0.outputs.result is a JSON string, not a deserialized map. You might be able to workaround this with fromJSON which recently became available as a new built-in function in expr 1.14. That new expr version is included in Argo 3.5.0-rc2 as well

miltalex commented 2 weeks ago

I still get the issue, I will have a look into this when I manage to find a bit of time.