{"record":{"id":"3b4bcd7d9719da69","repo":"argoproj/argo-workflows","slug":"failed-to-update-workflow-template-w-3b4bcd","errorCode":null,"errorMessage":"failed to update workflow template: %w","messagePattern":"failed to update workflow template: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/template/update.go","lineNumber":76,"sourceCode":"\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":58,"sourceCodeEnd":82,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/template/update.go#L58-L82","documentation":"After fetching the existing template's ResourceVersion, updateWorkflowTemplates calls UpdateWorkflowTemplate on the API server. If that call fails, the error is wrapped as `failed to update workflow template: %w`. The inner error carries the actual API failure — typically a validation rejection, conflict, or permission problem.","triggerScenarios":"The modified template fails schema/validation checks (invalid spec); a concurrent writer changed the ResourceVersion causing a conflict; RBAC denies `update workflowtemplates`; template is immutable in some field (e.g. changing certain metadata).","commonSituations":"Editing a spec with a schema error (bad template syntax) caught server-side; two operators updating the same template simultaneously; CI service account lacking update RBAC.","solutions":["Inspect the wrapped error — validation errors list the offending field; fix the YAML/spec accordingly.","Re-fetch the template and retry if the error is a conflict (stale ResourceVersion).","Verify RBAC: the caller needs `update` on `workflowtemplates` in the target namespace.","Run `argo lint` on the file before updating to catch spec errors client-side."],"exampleFix":"// before\nargo template update bad.yaml   # server rejects invalid spec\n// after\nargo lint bad.yaml              # catch validation first\nargo template update bad.yaml","handlingStrategy":"retry","validationCode":"argo lint file.yaml  # validate spec before updating","typeGuard":null,"tryCatchPattern":"for i := 0; i < 3; i++ {\n    _, err := client.UpdateWorkflowTemplate(ctx, req)\n    if err == nil { break }\n    if apierrors.IsConflict(err) { re-fetch resourceVersion; continue }\n    return err\n}","preventionTips":["Re-fetch the template immediately before update to get a fresh ResourceVersion","Run argo lint on the file before every update","Check for concurrent writers (CI + humans) on the same template","Verify update RBAC for the caller"],"tags":["cli","kubernetes-api","update","conflict","validation"],"backgroundTag":"kubernetes-update-conflict","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"}