{"record":{"id":"68d85c0640709725","repo":"argoproj/argo-workflows","slug":"failed-to-get-existing-workflow-template-q-to-upd","errorCode":null,"errorMessage":"failed to get existing workflow template %q to update: %w","messagePattern":"failed to get existing workflow template %q to update: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/template/update.go","lineNumber":68,"sourceCode":"\t\treturn err\n\t}\n\tserviceClient, err := apiClient.NewWorkflowTemplateServiceClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tworkflowTemplates := generateWorkflowTemplates(ctx, filePaths, cliOpts.strict)\n\n\tfor _, wftmpl := range workflowTemplates {\n\t\tif wftmpl.Namespace == \"\" {\n\t\t\twftmpl.Namespace = client.Namespace(ctx)\n\t\t}\n\t\tcurrent, err := serviceClient.GetWorkflowTemplate(ctx, &workflowtemplatepkg.WorkflowTemplateGetRequest{\n\t\t\tName:      wftmpl.Name,\n\t\t\tNamespace: wftmpl.Namespace,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get existing workflow template %q to update: %w\", wftmpl.Name, err)\n\t\t}\n\t\twftmpl.ResourceVersion = current.ResourceVersion\n\t\tupdated, err := serviceClient.UpdateWorkflowTemplate(ctx, &workflowtemplatepkg.WorkflowTemplateUpdateRequest{\n\t\t\tNamespace: wftmpl.Namespace,\n\t\t\tTemplate:  &wftmpl,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to update workflow template: %w\", err)\n\t\t}\n\t\tprintWorkflowTemplate(updated, cliOpts.output.String())\n\t}\n\treturn nil\n}\n","sourceCodeStart":50,"sourceCodeEnd":82,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/template/update.go#L50-L82","documentation":"`argo template update` (updateWorkflowTemplates) first GETs the existing WorkflowTemplate from the API server to learn its current state and populate the ResourceVersion for optimistic concurrency. If that GET fails, the update is aborted with `failed to get existing workflow template %q to update`. The wrapped error (`%w`) carries the real cause — usually the template does not exist or the API server is unreachable.","triggerScenarios":"`argo template update file.yaml` where the template name in the file does not exist in the target namespace; wrong --namespace or kubeconfig/context pointing at another cluster; API server connectivity failure or RBAC denying `get workflowtemplates`.","commonSituations":"Renamed templates (file has new name, cluster has old name); applying to the wrong namespace; expired/incorrect kubeconfig; service accounts without workflowtemplate get permission.","solutions":["Verify the template exists: `argo template get <name> -n <namespace>` or `kubectl get workflowtemplate <name> -n <namespace>`.","Fix the namespace in the file or pass the correct context: `kubectl config current-context` and `argo template update -n <ns> ...`.","Read the wrapped error for the root cause (NotFound vs Forbidden vs connection refused) and address accordingly.","Use `argo template create` (or `kubectl apply`) instead if the template is genuinely new."],"exampleFix":"// before\nargo template update my-tmpl.yaml -n wrong-ns\n// after\nargo template get my-tmpl -n default   # confirm it exists first\nargo template update my-tmpl.yaml -n default","handlingStrategy":"try-catch","validationCode":"kubectl get workflowtemplate <name> -n <ns> >/dev/null 2>&1 || echo \"template missing; use create/apply\"","typeGuard":"func isNotFound(err error) bool { return errors.Is(err, apierrors.IsNotFound(err.Error())) } // prefer apierrors.IsNotFound on the unwrapped cause","tryCatchPattern":"if err := update(...); err != nil {\n    if apierrors.IsNotFound(errors.Unwrap(err)) { create instead of update }\n    else if isForbidden(err) { check RBAC }\n    else { retry / report connectivity } \n}","preventionTips":["Confirm the template exists in the target namespace before update","Pin kubectl context and namespace explicitly in scripts","Run argo lint before update to catch unrelated spec errors","Grant CI service accounts get+update on workflowtemplates"],"tags":["cli","kubernetes-api","update","not-found"],"backgroundTag":"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"}