{"record":{"id":"e58ff407684dba57","repo":"argoproj/argo-workflows","slug":"404","errorCode":"404","errorMessage":"template %s not found","messagePattern":"template (.+?) not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/templateresolution/context.go","lineNumber":107,"sourceCode":"\n// NewContextFromClientSet returns new Context.\nfunc NewContextFromClientSet(wftmplClientset typed.WorkflowTemplateInterface, clusterWftmplClient typed.ClusterWorkflowTemplateInterface, tmplBase wfv1.TemplateHolder, workflow *wfv1.Workflow, log logging.Logger) *TemplateContext {\n\treturn &TemplateContext{\n\t\twftmplGetter:  WrapWorkflowTemplateInterface(wftmplClientset),\n\t\tcwftmplGetter: WrapClusterWorkflowTemplateInterface(clusterWftmplClient),\n\t\ttmplBase:      tmplBase,\n\t\tworkflow:      workflow,\n\t\tlog:           log,\n\t}\n}\n\n// GetTemplateByName returns a template by name in the context.\nfunc (tplCtx *TemplateContext) GetTemplateByName(ctx context.Context, name string) (*wfv1.Template, error) {\n\ttplCtx.log.WithField(\"name\", name).Debug(ctx, \"Getting the template by name\")\n\n\ttmpl := tplCtx.tmplBase.GetTemplateByName(name)\n\tif tmpl == nil {\n\t\treturn nil, errors.Errorf(errors.CodeNotFound, \"template %s not found\", name)\n\t}\n\n\tpodMetadata := tplCtx.tmplBase.GetPodMetadata()\n\ttplCtx.addPodMetadata(podMetadata, tmpl)\n\n\treturn tmpl.DeepCopy(), nil\n}\n\nfunc (tplCtx *TemplateContext) GetTemplateGetterFromRef(ctx context.Context, tmplRef *wfv1.TemplateRef) (wfv1.TemplateHolder, error) {\n\tif tmplRef.ClusterScope {\n\t\treturn tplCtx.cwftmplGetter.Get(ctx, tmplRef.Name)\n\t}\n\treturn tplCtx.wftmplGetter.Get(ctx, tmplRef.Name)\n}\n\n// GetTemplateFromRef returns a template found by a given template ref.\nfunc (tplCtx *TemplateContext) GetTemplateFromRef(ctx context.Context, tmplRef *wfv1.TemplateRef) (*wfv1.Template, error) {\n\ttplCtx.log.Debug(ctx, \"Getting the template from ref\")","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/templateresolution/context.go#L89-L125","documentation":"TemplateContext.GetTemplateByName resolves a template by name from the template base (workflow, WorkflowTemplate, or ClusterWorkflowTemplate already loaded into context). If no template with that name exists in the base, it returns a 404 CodeNotFound error so callers (validation, GetTemplate) fail with a clear not-found message.","triggerScenarios":"Calling GetTemplate/GetTemplateByName with a template name that doesn't exist in the referenced template holder; validateTemplateHolder on a spec whose templates list lacks the referenced name.","commonSituations":"Typos in template names; steps/tasks referencing templates removed during refactoring; templateRef pointing to a template that exists in a different WorkflowTemplate than the one named.","solutions":["Correct the template name in the step/task/templateRef","Verify the referenced WorkflowTemplate actually contains the template","Run `argo lint` before submitting to catch missing templates"],"exampleFix":"// before\n- name: step-a\n  template: build-image  # does not exist\n// after\n- name: step-a\n  template: build  # matches templates[].name in the spec","handlingStrategy":"validation","validationCode":"// pre-check that the template exists in the holder\nnames := set(tmplBase.Templates.map(t => t.Name))\nfor (const ref of allTemplateRefs(wf)) {\n  if (!names.has(ref)) throw new Error(`template ${ref} not found`)\n}","typeGuard":null,"tryCatchPattern":"tmpl, err := tplCtx.GetTemplateByName(ctx, name)\nif err != nil {\n  var nf *errors.ArgoError\n  if errors.As(err, &nf) && nf.Code() == 404 {\n    return fmt.Errorf(\"template %q missing from spec; run argo lint\", name)\n  }\n  return err\n}","preventionTips":["Run `argo lint` before every submit","Keep template names consistent with a naming convention","Check templateRef targets exist in the named WorkflowTemplate/ClusterWorkflowTemplate"],"tags":["kubernetes","template-resolution","not-found","argo-workflows"],"backgroundTag":"template-not-found","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"}