@@ -12,6 +12,7 @@ import (
1212 wfv1 "github.com/argoproj/argo-workflows/v4/pkg/apis/workflow/v1alpha1"
1313 "github.com/argoproj/argo-workflows/v4/util/logging"
1414 "github.com/argoproj/argo-workflows/v4/util/variables"
15+ varkeys "github.com/argoproj/argo-workflows/v4/util/variables/keys"
1516)
1617
1718// TestStepsFailedRetries ensures a steps template will recognize exhausted retries
@@ -82,6 +83,28 @@ func TestArtifactResolutionWhenSkipped(t *testing.T) {
8283 assert .Equal (t , wfv1 .WorkflowSucceeded , woc .wf .Status .Phase )
8384}
8485
86+ func TestResolveReferencesSkipsOptionalArtifactFromSkippedStep (t * testing.T ) {
87+ ctx := logging .TestContext (t .Context ())
88+ woc := newWoc (ctx , wfv1.Workflow {})
89+ scope := createScope (nil )
90+ varkeys .StepsNodeRef .OutputsArtifactByName .Set (scope .scope , wfv1.Artifact {}, "generate" , "message" )
91+ stepGroup := []wfv1.WorkflowStep {{
92+ Name : "consume" ,
93+ Template : "consumer" ,
94+ Arguments : wfv1.Arguments {Artifacts : wfv1.Artifacts {{
95+ Name : "message" ,
96+ From : "{{steps.generate.outputs.artifacts.message}}" ,
97+ Optional : true ,
98+ }}},
99+ }}
100+
101+ resolvedSteps , err := woc .resolveReferences (ctx , stepGroup , scope )
102+
103+ require .NoError (t , err )
104+ require .Len (t , resolvedSteps , 1 )
105+ assert .Empty (t , resolvedSteps [0 ].Arguments .Artifacts )
106+ }
107+
85108var stepsWithParamAndGlobalParam = `
86109apiVersion: argoproj.io/v1alpha1
87110kind: Workflow
0 commit comments