{"record":{"id":"a72850a1b6d8bfd3","repo":"argoproj/argo-workflows","slug":"unable-to-parse-argo-variable-w","errorCode":null,"errorMessage":"unable to parse argo variable: %w","messagePattern":"unable to parse argo variable: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/steps.go","lineNumber":646,"sourceCode":"\t\t}\n\tdefault:\n\t\t// this should have been prevented in expandStepGroup()\n\t\treturn nil, argoerrors.InternalError(\"expandStep() was called with withItems and withParam empty\")\n\t}\n\n\t// these fields can be very large (>100m) and marshalling 10k x 100m = 6GB of memory used and\n\t// very poor performance, so we just nil them out\n\tstep.WithItems = nil\n\tstep.WithParam = \"\"\n\tstep.WithSequence = nil\n\n\tstepBytes, err := json.Marshal(step)\n\tif err != nil {\n\t\treturn nil, argoerrors.InternalWrapError(err)\n\t}\n\tt, err := template.NewTemplate(string(stepBytes))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse argo variable: %w\", err)\n\t}\n\n\tfor i, item := range items {\n\t\tvar newStep wfv1.WorkflowStep\n\t\tnewStepName, err := processItem(ctx, t, step.Name, i, item, &newStep, step.When, scope.getParametersAny(woc.globalParams()))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tnewStep.Name = newStepName\n\t\tnewStep.Template = step.Template\n\t\texpandedStep = append(expandedStep, newStep)\n\t}\n\treturn expandedStep, nil\n}\n\nfunc (woc *wfOperationCtx) prepareDefaultMetricScope() (map[string]any, map[string]func() float64) {\n\tlocalScope := template.ToAnyMap(woc.globalParams())\n\tlocalScope[varkeys.MetricDuration.Template()] = \"0\"","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/steps.go#L628-L664","documentation":"expandStep marshals the step template to JSON and runs template.NewTemplate to validate/parse its argo variables. If the template syntax is invalid (unbalanced braces, malformed {{...}} expressions), expansion of withItems/withParam fails with this wrapped parse error.","triggerScenarios":"expandStep on a step using withItems/withMap/withParam where the step's templated strings contain malformed argo variable syntax that template.NewTemplate cannot parse.","commonSituations":"Unbalanced {{ }} braces, stray single braces, invalid expression syntax inside item loops; YAML anchors producing odd strings; typos like {{item}} misspellings.","solutions":["Fix the malformed {{...}} expression in the step template","Validate the workflow with argo lint before submitting","Escape literal braces or move complex expressions into scripts"],"exampleFix":"// before\n- name: fanout\n  template: echo\n  withItems: [1, 2]\n  arguments:\n    parameters:\n      - name: msg\n        value: 'hello {{item}} }' # unbalanced brace\n// after\n  arguments:\n    parameters:\n      - name: msg\n        value: 'hello {{item}}'","handlingStrategy":"validation","validationCode":"// check for balanced braces in templated strings before submit\nfunc balancedBraces(s string) bool { c := 0; for _, r := range s { if r=='{' {c++}; if r=='}' {c--}; if c>1||c<0 {return false} }; return c==0 }","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"unable to parse argo variable\") {\n    // fix malformed {{...}} in the step template and resubmit\n}","preventionTips":["Run argo lint in CI","Avoid stray braces in parameter values","Prefer simple expressions; escape literals"],"tags":["kubernetes","argo-workflows","templating","steps"],"backgroundTag":"template-parse-error","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}