{"record":{"id":"2c8f7428fb240f68","repo":"argoproj/argo-workflows","slug":"failed-to-create-cluster-workflow-template-s","errorCode":null,"errorMessage":"failed to create cluster workflow template: %s,  %w","messagePattern":"failed to create cluster workflow template: (.+?),  %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/clustertemplate/create.go","lineNumber":64,"sourceCode":"\t\tcliOpts = &cliCreateOpts{}\n\t}\n\tctx, apiClient, err := client.NewAPIClient(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tserviceClient, err := apiClient.NewClusterWorkflowTemplateServiceClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclusterWorkflowTemplates := generateClusterWorkflowTemplates(ctx, filePaths, cliOpts.strict)\n\n\tfor _, wftmpl := range clusterWorkflowTemplates {\n\t\tcreated, err := serviceClient.CreateClusterWorkflowTemplate(ctx, &clusterworkflowtemplate.ClusterWorkflowTemplateCreateRequest{\n\t\t\tTemplate: &wftmpl,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create cluster workflow template: %s,  %w\", wftmpl.Name, err)\n\t\t}\n\t\tprintClusterWorkflowTemplate(created, cliOpts.output.String())\n\t}\n\treturn nil\n}\n","sourceCodeStart":46,"sourceCodeEnd":70,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/clustertemplate/create.go#L46-L70","documentation":"Thrown by `argo cluster-template create` (createClusterWorkflowTemplates in cmd/argo/commands/clustertemplate/create.go) when CreateClusterWorkflowTemplate fails for a named template; the error wraps the template name and the server-side cause. ClusterWorkflowTemplates are cluster-scoped, so this typically reflects permissions or an existing template rather than namespace issues.","triggerScenarios":"Submitting one or more ClusterWorkflowTemplate manifests where the argo server rejects creation: an identical template name already exists (already-exists error), the caller's RBAC/SSO role lacks create on clusterworkflowtemplates, or the template payload fails server-side validation.","commonSituations":"Re-running `argo cluster-template create -f templates.yaml` without delete/update (idempotency); service accounts without cluster-scoped RBAC in SSO mode; invalid template YAML passing lint locally but failing server validation; multi-doc files where one bad template aborts the loop after earlier ones were created (partial application).","solutions":["Read the wrapped cause: 'already exists' means use `argo cluster-template update` or `argo cluster-template delete` then re-create.","Check RBAC: ensure your SA/SSO group has create permission on clusterworkflowtemplates.argoproj.io at cluster scope.","Run `argo lint` on the file first to catch template validation issues before submission.","If a batch file partially applied, delete the already-created templates before re-running, or create templates individually."],"exampleFix":"// before\nargo cluster-template create -f cwf.yaml   // failed to create ...: already exists\n\n// after\nargo cluster-template update -f cwf.yaml   # or delete then create","handlingStrategy":"try-catch","validationCode":"// lint before create\nif err := validate.ClusterWorkflowTemplate(nil, &tmpl); err != nil {\n    return fmt.Errorf(\"template %s invalid: %w\", tmpl.Name, err)\n}\n// check existence to avoid already-exists\n_, err := serviceClient.GetClusterWorkflowTemplate(ctx, &clusterworkflowtemplate.ClusterWorkflowTemplateGetRequest{Name: tmpl.Name})","typeGuard":null,"tryCatchPattern":"_, err := serviceClient.CreateClusterWorkflowTemplate(ctx, req)\nif err != nil {\n    if apierr.IsAlreadyExists(err) {\n        _, err = serviceClient.UpdateClusterWorkflowTemplate(ctx, &clusterworkflowtemplate.ClusterWorkflowTemplateUpdateRequest{Name: tmpl.Name, Template: tmpl})\n    }\n    return err\n}","preventionTips":["Use create-or-update (upsert) logic for idempotent template deployment.","Lint cluster templates in CI before applying.","Ensure RBAC grants create on clusterworkflowtemplates at cluster scope.","Apply multi-doc files per-template so one failure does not leave partial state."],"tags":["argo-workflows","cluster-workflow-template","rbac","cli"],"backgroundTag":"cluster-template-create-failed","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"}