{"record":{"id":"049a026f7acd98b3","repo":"argoproj/argo-workflows","slug":"500","errorCode":"500","errorMessage":"failed to get a template","messagePattern":"failed to get a template","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/templateresolution/context.go","lineNumber":164,"sourceCode":"\t}\n\n\tpodMetadata := wftmpl.GetPodMetadata()\n\ttplCtx.addPodMetadata(podMetadata, template)\n\n\treturn template.DeepCopy(), nil\n}\n\n// GetTemplate returns a template found by template name or template ref.\nfunc (tplCtx *TemplateContext) GetTemplate(ctx context.Context, h wfv1.TemplateReferenceHolder) (*wfv1.Template, error) {\n\ttplCtx.log.Debug(ctx, \"Getting the template\")\n\tif x := h.GetTemplate(); x != nil {\n\t\treturn x, nil\n\t} else if x := h.GetTemplateRef(); x != nil {\n\t\treturn tplCtx.GetTemplateFromRef(ctx, x)\n\t} else if x := h.GetTemplateName(); x != \"\" {\n\t\treturn tplCtx.GetTemplateByName(ctx, x)\n\t}\n\treturn nil, errors.Errorf(errors.CodeInternal, \"failed to get a template\")\n}\n\n// GetCurrentTemplateBase returns the current template base of the context.\nfunc (tplCtx *TemplateContext) GetCurrentTemplateBase() wfv1.TemplateHolder {\n\treturn tplCtx.tmplBase\n}\n\nfunc (tplCtx *TemplateContext) GetTemplateScope() string {\n\treturn string(tplCtx.tmplBase.GetResourceScope()) + \"/\" + tplCtx.tmplBase.GetName()\n}\n\n// ResolveTemplate digs into referenes and returns a merged template.\n// This method is the public start point of template resolution.\nfunc (tplCtx *TemplateContext) ResolveTemplate(c context.Context, tmplHolder wfv1.TemplateReferenceHolder) (*TemplateContext, *wfv1.Template, bool, error) {\n\treturn tplCtx.resolveTemplateImpl(c, tmplHolder)\n}\n\n// resolveTemplateImpl digs into references and returns a merged template.","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/templateresolution/context.go#L146-L182","documentation":"GetTemplate walks a template holder's three reference mechanisms in priority order: inline template (GetTemplate), templateRef (GetTemplateFromRef), then templateName (GetTemplateByName). If none of the three is populated — the holder has no template, no templateRef, and an empty templateName — the code falls through and raises a coded internal error (errors.CodeInternal, HTTP 500). Unlike the 404s, this indicates a malformed spec rather than missing cluster state.","triggerScenarios":"Calling GetTemplate (via ResolveTemplate during validation or controller execution) on a TemplateReferenceHolder (e.g. a workflow step/node) whose template, templateRef, and templateName fields are all unset/empty — typically only possible with a programmatically constructed or corrupted object.","commonSituations":"Hand-crafted workflow YAML where a step declares neither `template:` nor `templateRef:`; a controller/tool that builds Workflow nodes without setting any template reference; bugs in custom automation that mutates workflow specs (stripping template fields).","solutions":["Inspect the offending holder in the workflow spec and set a valid `template:` name, `templateRef:`, or inline `template:` block.","Run `argo lint` on the workflow/WorkflowTemplate to catch templates missing a reference before submission.","If a custom tool builds the spec, fix it to always populate one of the three template reference fields."],"exampleFix":"# before\n- name: step-one\n  args: [\"--flag\"]      # no template reference at all\n# after\n- name: step-one\n  template: run-job     # or templateRef / inline template\n  args: [\"--flag\"]","handlingStrategy":"validation","validationCode":"# shell: every step/dag task must reference a template somehow\nyq '.spec.templates[] | select((.template == null) and (.templateRef == null) and ((.templateName // \"\") == \"\")) | .name' workflow.yaml\n# any output = spec will hit the internal error","typeGuard":null,"tryCatchPattern":"// Go: treat CodeInternal here as a spec bug, not a runtime condition\ntmpl, err := tplCtx.GetTemplate(ctx, holder)\nif err != nil {\n\tif argoErr, ok := err.(errors.ArgoError); ok && argoErr.Code() == errors.CodeInternal {\n\t\treturn fmt.Errorf(\"holder %v declares no template/templateRef/templateName — fix the spec\", holder)\n\t}\n\treturn err\n}","preventionTips":["Run `argo lint` on every generated or hand-written workflow before submission.","When generating workflows programmatically, assert each node/step sets exactly one of template, templateRef, or templateName.","Avoid custom mutation that strips template fields from workflow specs."],"tags":["internal-error","workflow-spec","template-resolution"],"backgroundTag":"missing-template-reference","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"}