Skip to content

Conversation

@tczhao
Copy link
Member

@tczhao tczhao commented Sep 12, 2025

Fixes #14042 #13773

Before this fix, the validation will failed if workflow contains dynamic templateRef.
Decide to skip validate dynamic templateRef instead of find a way to validate them due to the complexity and cases where its impossible to validate

  • e.g. the templateRef depends on the output from a previous step

Motivation

Modifications

Verification

Added test for dynamic templateRef validation. copy from #14053
Added test to validate the regression introduced by previous templateRef validation implementation attempt

Documentation

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Tianchu Zhao <[email protected]>
@tczhao tczhao changed the title fix: validate dynamic templateref fix: skip validate dynamic templateref Sep 12, 2025
@tczhao tczhao marked this pull request as ready for review September 12, 2025 16:06
@tczhao tczhao requested a review from Joibel September 30, 2025 05:13
Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion

tmplCtx, resolvedTmpl, _, err := tmplCtx.ResolveTemplate(ctx, tmplHolder)
if err != nil {
if argoerr, ok := err.(errors.ArgoError); ok && argoerr.Code() == errors.CodeNotFound {
if tmplRef != nil && strings.Contains(tmplRef.Template, "placeholder") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it less likely to mismatch on non-placeholder templates with

Suggested change
if tmplRef != nil && strings.Contains(tmplRef.Template, "placeholder") {
if tmplRef != nil && strings.HasPrefix(tmplRef.Template, "placeholder") {

Copy link
Member Author

@tczhao tczhao Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dynamic template parameter can be partial, using prefix matching won't cover the following use case.
e.g.
"prod-{{ inputs.parameters.message }}" this will translate to prod-placeholder-x.

If a user uses string:placeholder in templateRef, the worst-case scenario is that they experience an issue during runtime instead of catch it at the validation phase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that, understand

@tczhao tczhao requested a review from Joibel October 3, 2025 03:26
tmplCtx, resolvedTmpl, _, err := tmplCtx.ResolveTemplate(ctx, tmplHolder)
if err != nil {
if argoerr, ok := err.(errors.ArgoError); ok && argoerr.Code() == errors.CodeNotFound {
if tmplRef != nil && strings.Contains(tmplRef.Template, "placeholder") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that, understand

@Joibel Joibel merged commit d1b280e into argoproj:main Oct 6, 2025
43 checks passed
survivant pushed a commit to survivant/argo-workflows that referenced this pull request Oct 7, 2025
Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Sebastien Dionne <[email protected]>
ItielOlenick pushed a commit to ItielOlenick/argo-workflows that referenced this pull request Oct 26, 2025
@Joibel Joibel added cherry-pick/3.7 Cherry-pick this to release-3.7 cherry-pick/3.6 Cherry-pick this to release-3.6 labels Nov 26, 2025
@argo-cd-cherry-pick-bot
Copy link

❌ Cherry-pick failed for 3.6. Please check the workflow logs for details.

@argo-cd-cherry-pick-bot
Copy link

❌ Cherry-pick failed for 3.7. Please check the workflow logs for details.

Joibel pushed a commit that referenced this pull request Nov 26, 2025
(cherry picked from commit d1b280e)

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Joibel pushed a commit that referenced this pull request Nov 26, 2025
(cherry picked from commit d1b280e)

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Joibel pushed a commit that referenced this pull request Nov 26, 2025
(cherry picked from commit d1b280e)

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Joibel pushed a commit that referenced this pull request Nov 26, 2025
(cherry picked from commit d1b280e)

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Joibel added a commit that referenced this pull request Nov 26, 2025
…15082)

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Co-authored-by: Tianchu Zhao <[email protected]>
Joibel added a commit that referenced this pull request Nov 26, 2025
…15081)

Signed-off-by: Tianchu Zhao <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Co-authored-by: Tianchu Zhao <[email protected]>
guanguxiansheng pushed a commit to guanguxiansheng/argo-workflows that referenced this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/3.6 Cherry-pick this to release-3.6 cherry-pick/3.7 Cherry-pick this to release-3.7

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dynamic template naming on workflowTemplates fails unexpectedly

2 participants