argo-workflows icon indicating copy to clipboard operation
argo-workflows copied to clipboard

Unable to resolve output artifact of steps from expression when it refers to its own input artifact

Open zjgemi opened this issue 2 years ago • 5 comments

Summary

I'm trying to assign an output artifact of steps using fromExpression. When the expression contains reference of an input artifact of the same steps, Argo fails to resolve it. Interestingly, using from instead of fromExpression works.

Diagnostics

The smallest workflow that reproduces the bug

kind: Workflow
metadata:
  generateName: from-expression-bug-
spec:
  entrypoint: main
  arguments:
    artifacts:
    - name: foo
      raw:
        data: |
          Hello
  templates:
    - name: main
      inputs:
        artifacts:
        - name: foo
      steps:
      - - name: hello
          inline:
            container:
              image: alpine:latest
      outputs:
        artifacts:
        - name: result
          # a trivial expression here only for reproducing the bug
          fromExpression: "1 == 1 ? inputs.artifacts.foo : inputs.artifacts.foo"

When the workflow is submitted, the steps becomes error with message:

unable to resolve outputs from scope: Variable {{&Artifact{Name:result,Path:,Mode:nil,From:,ArtifactLocation:ArtifactLocation{ArchiveLogs:nil,S3:nil,Git:nil,HTTP:nil,Artifactory:nil,HDFS:nil,Raw:nil,OSS:nil,GCS:nil,},GlobalName:,Archive:nil,Optional:false,SubPath:,RecurseMode:false,FromExpression:1 == 1 ? inputs.artifacts.foo : inputs.artifacts.foo,ArtifactGC:nil,Deleted:false,}}} is not an artifact
截屏2022-07-07 下午2 30 06

While the workflow using from instead of fromExpression

kind: Workflow
metadata:
  generateName: from-expression-bug-
spec:
  entrypoint: main
  arguments:
    artifacts:
    - name: foo
      raw:
        data: |
          Hello
  templates:
    - name: main
      inputs:
        artifacts:
        - name: foo
      steps:
      - - name: hello
          inline:
            container:
              image: alpine:latest
      outputs:
        artifacts:
        - name: result
          from: "inputs.artifacts.foo"

will not encounter the error.


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

zjgemi avatar Jul 07 '22 06:07 zjgemi

@zjgemi Hello, what is your use case for these artifacts in this scope?

dpadhiar avatar Jul 07 '22 20:07 dpadhiar

@zjgemi Hello, what is your use case for these artifacts in this scope? In my case I have a conditional step. If the step is not skipped, the next step uses its output artifact, otherwise the next step uses my input artifact directly. Due to conditional artifacts only supported when assigning output artifacts, I construct a steps template to do this.

zjgemi avatar Jul 08 '22 09:07 zjgemi

@dpadhiar we need to include the input.artifacts in scope

sarabala1979 avatar Jul 11 '22 14:07 sarabala1979

@sarabala1979 Will do.

dpadhiar avatar Jul 11 '22 15:07 dpadhiar

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.

stale[bot] avatar Jul 31 '22 04:07 stale[bot]

This issue has been closed due to inactivity. Feel free to re-open if you still encounter this issue.

stale[bot] avatar Aug 12 '22 13:08 stale[bot]