argoproj/argo-workflows · error
failed to create cluster workflow template: %s, %w
Error message
failed to create cluster workflow template: %s, %w
What it means
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.
Source
Thrown at cmd/argo/commands/clustertemplate/create.go:64
cliOpts = &cliCreateOpts{}
}
ctx, apiClient, err := client.NewAPIClient(ctx)
if err != nil {
return err
}
serviceClient, err := apiClient.NewClusterWorkflowTemplateServiceClient()
if err != nil {
return err
}
clusterWorkflowTemplates := generateClusterWorkflowTemplates(ctx, filePaths, cliOpts.strict)
for _, wftmpl := range clusterWorkflowTemplates {
created, err := serviceClient.CreateClusterWorkflowTemplate(ctx, &clusterworkflowtemplate.ClusterWorkflowTemplateCreateRequest{
Template: &wftmpl,
})
if err != nil {
return fmt.Errorf("failed to create cluster workflow template: %s, %w", wftmpl.Name, err)
}
printClusterWorkflowTemplate(created, cliOpts.output.String())
}
return nil
}
View on GitHub (pinned to 35bff19146)
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.
Example fix
// before argo cluster-template create -f cwf.yaml // failed to create ...: already exists // after argo cluster-template update -f cwf.yaml # or delete then create
Defensive patterns
Strategy: try-catch
Validate before calling
// lint before create
if err := validate.ClusterWorkflowTemplate(nil, &tmpl); err != nil {
return fmt.Errorf("template %s invalid: %w", tmpl.Name, err)
}
// check existence to avoid already-exists
_, err := serviceClient.GetClusterWorkflowTemplate(ctx, &clusterworkflowtemplate.ClusterWorkflowTemplateGetRequest{Name: tmpl.Name}) Try / catch
_, err := serviceClient.CreateClusterWorkflowTemplate(ctx, req)
if err != nil {
if apierr.IsAlreadyExists(err) {
_, err = serviceClient.UpdateClusterWorkflowTemplate(ctx, &clusterworkflowtemplate.ClusterWorkflowTemplateUpdateRequest{Name: tmpl.Name, Template: tmpl})
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- resolve UID: %w
- resolve UID: %w
- resolve UID: %w
- unable to parse node field selector '%s': %w
- resolve UID: %w
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/2c8f7428fb240f68.
Report an issue: GitHub.