{"record":{"id":"8a611e7b9f31bc8c","repo":"argoproj/argo-workflows","slug":"failed-to-get-workflow-template-w","errorCode":null,"errorMessage":"failed to get workflow template: %w","messagePattern":"failed to get workflow template: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/event/dispatch/operation.go","lineNumber":110,"sourceCode":"\tmatched, err := argoexpr.EvalBool(selector, o.env)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to evaluate workflow template expression: %w\", err)\n\t}\n\tlogger.WithFields(logging.Fields{\"namespace\": wfeb.Namespace, \"event\": wfeb.Name, \"selector\": selector, \"matched\": matched}).Debug(ctx, \"Selector evaluation\")\n\tsubmit := wfeb.Spec.Submit\n\tif matched && submit != nil {\n\t\t//nolint: contextcheck\n\t\tclient := auth.GetWfClient(o.ctx)\n\t\tref := wfeb.Spec.Submit.WorkflowTemplateRef\n\t\tvar tmpl wfv1.WorkflowSpecHolder\n\t\tvar err error\n\t\tif ref.ClusterScope {\n\t\t\ttmpl, err = client.ArgoprojV1alpha1().ClusterWorkflowTemplates().Get(ctx, ref.Name, metav1.GetOptions{})\n\t\t} else {\n\t\t\ttmpl, err = client.ArgoprojV1alpha1().WorkflowTemplates(wfeb.Namespace).Get(ctx, ref.Name, metav1.GetOptions{})\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to get workflow template: %w\", err)\n\t\t}\n\t\terr = o.instanceIDService.Validate(tmpl)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to validate workflow template instanceid: %w\", err)\n\t\t}\n\t\twf := common.NewWorkflowFromWorkflowTemplate(tmpl.GetName(), ref.ClusterScope)\n\n\t\t// Apply workflowMetadata labels and annotations from the template\n\t\t// at creation time, matching the CronWorkflow behavior.\n\t\t// labelsFrom is left to the controller since it\n\t\t// requires parameter evaluation at runtime.\n\t\tif wmd := tmpl.GetWorkflowSpec().WorkflowMetadata; wmd != nil {\n\t\t\tmaps.Copy(wf.Labels, wmd.Labels)\n\t\t\tif len(wmd.Annotations) > 0 {\n\t\t\t\tmaps.Copy(wf.Annotations, wmd.Annotations)\n\t\t\t}\n\t\t}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/server/event/dispatch/operation.go#L92-L128","documentation":"The Argo Server's event dispatch (WorkflowEventBinding consumer) failed to fetch the WorkflowTemplate referenced by `spec.submit.workflowTemplateRef` before submitting a workflow. It reads via ClusterWorkflowTemplates when `clusterScope: true`, otherwise namespaced WorkflowTemplates in the binding's namespace, and wraps any k8s API error. This is a user/configuration-facing failure surfaced as a Warning event `WorkflowEventBindingError` on the binding.","triggerScenarios":"An event (e.g. via `argo submit --from` / eventsource posting to the event API) matched the WorkflowEventBinding selector, but `WorkflowTemplates(wfeb.Namespace).Get(ctx, ref.Name)` or `ClusterWorkflowTemplates().Get(ctx, ref.Name)` returned an error: template not found (NotFound), RBAC denied (Forbidden), wrong namespace in the ref, or transient API server errors (retried only if errorsutil.IsTransientErr deems them so).","commonSituations":"Typo in workflowTemplateRef.name; template deleted after the binding was created; template lives in a different namespace than the WorkflowEventBinding; clusterScope=true but the template is only namespaced (or vice versa); SSO/server service account lacks argoproj.io workflowtemplates get permission in that namespace.","solutions":["Check the exact referenced name: run `kubectl get workflowtemplates -n <wfeb-namespace>` (or `kubectl get clusterworkflowtemplates` if clusterScope: true) and fix any typo in spec.submit.workflowTemplateRef.name.","Ensure the template is in the same namespace as the WorkflowEventBinding unless clusterScope: true; move the template or set clusterScope correctly.","Verify RBAC: the server's service account (or SSO-mapped SA) needs get on workflowtemplates.argoproj.io in the target namespace/cluster; adjust RBAC roles.","Inspect the wrapped k8s error in the Warning event on the WorkflowEventBinding to distinguish NotFound vs Forbidden vs transient errors.","If the error was transient (API server blip), check controller/server logs; non-transient errors are recorded as `WorkflowEventBindingError` events and the dispatch fails for that binding."],"exampleFix":"# before (binding points at missing/wrong template)\nspec:\n  submit:\n    workflowTemplateRef:\n      name: my-worfklow-template\n# after\nspec:\n  submit:\n    workflowTemplateRef:\n      name: my-workflow-template","handlingStrategy":"validation","validationCode":"# before creating/applying the WorkflowEventBinding\nkubectl get workflowtemplate <ref-name> -n <binding-namespace>\n# or if clusterScope: true\nkubectl get clusterworkflowtemplate <ref-name>","typeGuard":null,"tryCatchPattern":"// wrap event dispatch submission\n_, err := op.Dispatch(ctx)\nif err != nil && strings.Contains(err.Error(), \"failed to get workflow template\") {\n    logger.Errorf(ctx, \"check workflowTemplateRef name/namespace and RBAC: %v\", err)\n}","preventionTips":["Create the WorkflowTemplate in the same namespace as the WorkflowEventBinding unless intentionally using clusterScope.","Reference templates via one source of truth (GitOps) so binding and template names stay in sync.","Grant the argo-server service account get on workflowtemplates/clusterworkflowtemplates in target namespaces.","Monitor WorkflowEventBinding Warning events (WorkflowEventBindingError) for failed dispatches."],"tags":["kubernetes","workflow-event-binding","not-found","rbac","argo-workflows"],"backgroundTag":"kubernetes-resource-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"}