{"record":{"id":"e94617702f81683b","repo":"argoproj/argo-workflows","slug":"can-t-find-template-with-name-q","errorCode":null,"errorMessage":"can't find template with name %q","messagePattern":"can't find template with name %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/artifact_gc.go","lineNumber":394,"sourceCode":"\n// create the Pod which will do the deletions\nfunc (woc *wfOperationCtx) createArtifactGCPod(ctx context.Context, strategy wfv1.ArtifactGCStrategy, tasks []*wfv1.WorkflowArtifactGCTask,\n\tinfo podInfo, podName string, templatesToArtList templatesToArtifacts, templatesByName map[string]*wfv1.Template) (*corev1.Pod, error) {\n\twoc.log.WithFields(logging.Fields{\"strategy\": strategy, \"podName\": podName}).Info(ctx, \"creating pod to delete artifacts\")\n\n\t// Pod is owned by WorkflowArtifactGCTasks, so it will die automatically when all of them have died\n\townerReferences := make([]metav1.OwnerReference, len(tasks))\n\tfor i, task := range tasks {\n\t\t// make sure pod gets deleted with the WorkflowArtifactGCTasks\n\t\townerReferences[i] = *metav1.NewControllerRef(task, wfv1.SchemeGroupVersion.WithKind(workflow.WorkflowArtifactGCTaskKind))\n\t}\n\n\tartifactLocations := make([]*wfv1.ArtifactLocation, 0)\n\n\tfor templateName, artifacts := range templatesToArtList {\n\t\ttemplate, found := templatesByName[templateName]\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"can't find template with name %q\", templateName)\n\t\t}\n\n\t\tif template.ArchiveLocation.HasLocation() {\n\t\t\tartifactLocations = append(artifactLocations, template.ArchiveLocation)\n\t\t} else {\n\t\t\tartifactLocations = append(artifactLocations, woc.artifactRepository.ToArtifactLocation())\n\t\t}\n\t\tfor i := range artifacts {\n\t\t\tartifactLocations = append(artifactLocations, &artifacts[i].ArtifactLocation)\n\t\t}\n\t}\n\n\tvolumes, volumeMounts := createSecretVolumesAndMountsFromArtifactLocations(artifactLocations)\n\n\tpluginNames := make(map[wfv1.ArtifactPluginName]bool, 0)\n\tfor _, artifactLocation := range artifactLocations {\n\t\tif artifactLocation != nil && artifactLocation.Plugin != nil && artifactLocation.Plugin.Name != \"\" {\n\t\t\tpluginNames[artifactLocation.Plugin.Name] = true","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/artifact_gc.go#L376-L412","documentation":"createArtifactGCPod iterates templatesToArtList and resolves each template from the templatesByName map built earlier in processArtifactGCStrategy. If a key is missing, the map and artifact list are out of sync. Thrown at workflow/controller/artifact_gc.go:394; like error 551 it guards an internal invariant and is normally unreachable with upstream code.","triggerScenarios":"templatesToArtList contains a templateName key absent from templatesByName. Both are populated from the same resolution pass, so this fires only from code modifications, map mutation between passes, or a nil template being cached under its name in a fork.","commonSituations":"Patched/forked controller code altering the templatesByName population; upstream bug reports concerning map consistency during artifact GC strategy processing.","solutions":["Run unmodified upstream workflow-controller; rebuild the image if artifact_gc.go was customized.","Enable debug logging (logging.globalLevel=debug) and capture the 'list of artifacts pertaining to template' lines to identify the inconsistent template name.","Report the issue upstream with controller version and workflow spec.","As a workaround, use spec.artifactGC.forceFinalizerRemoval: true and remove artifacts manually."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"can't find template with name\") { /* internal inconsistency: report upstream, use forceFinalizerRemoval workaround */ }","preventionTips":["Run stock controller images without local patches to artifact_gc.go.","Keep the controller up to date with upstream fixes.","If hit, gather debug logs for the upstream issue report."],"tags":["kubernetes","artifact-gc","internal-state","workflow-controller"],"backgroundTag":"internal-invariant-violation","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"}