argoproj/argo-workflows · error

failed to get existing workflow template %q to update: %w

Error message

failed to get existing workflow template %q to update: %w

What it means

`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.

Source

Thrown at cmd/argo/commands/template/update.go:68

		return err
	}
	serviceClient, err := apiClient.NewWorkflowTemplateServiceClient()
	if err != nil {
		return err
	}

	workflowTemplates := generateWorkflowTemplates(ctx, filePaths, cliOpts.strict)

	for _, wftmpl := range workflowTemplates {
		if wftmpl.Namespace == "" {
			wftmpl.Namespace = client.Namespace(ctx)
		}
		current, err := serviceClient.GetWorkflowTemplate(ctx, &workflowtemplatepkg.WorkflowTemplateGetRequest{
			Name:      wftmpl.Name,
			Namespace: wftmpl.Namespace,
		})
		if err != nil {
			return fmt.Errorf("failed to get existing workflow template %q to update: %w", wftmpl.Name, err)
		}
		wftmpl.ResourceVersion = current.ResourceVersion
		updated, err := serviceClient.UpdateWorkflowTemplate(ctx, &workflowtemplatepkg.WorkflowTemplateUpdateRequest{
			Namespace: wftmpl.Namespace,
			Template:  &wftmpl,
		})
		if err != nil {
			return fmt.Errorf("failed to update workflow template: %w", err)
		}
		printWorkflowTemplate(updated, cliOpts.output.String())
	}
	return nil
}

View on GitHub (pinned to 35bff19146)

Solutions

  1. Verify the template exists: `argo template get <name> -n <namespace>` or `kubectl get workflowtemplate <name> -n <namespace>`.
  2. Fix the namespace in the file or pass the correct context: `kubectl config current-context` and `argo template update -n <ns> ...`.
  3. Read the wrapped error for the root cause (NotFound vs Forbidden vs connection refused) and address accordingly.
  4. Use `argo template create` (or `kubectl apply`) instead if the template is genuinely new.

Example fix

// before
argo template update my-tmpl.yaml -n wrong-ns
// after
argo template get my-tmpl -n default   # confirm it exists first
argo template update my-tmpl.yaml -n default
Defensive patterns

Strategy: try-catch

Validate before calling

kubectl get workflowtemplate <name> -n <ns> >/dev/null 2>&1 || echo "template missing; use create/apply"

Type guard

func isNotFound(err error) bool { return errors.Is(err, apierrors.IsNotFound(err.Error())) } // prefer apierrors.IsNotFound on the unwrapped cause

Try / catch

if err := update(...); err != nil {
    if apierrors.IsNotFound(errors.Unwrap(err)) { create instead of update }
    else if isForbidden(err) { check RBAC }
    else { retry / report connectivity } 
}

Prevention

When it happens

Trigger: `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`.

Common situations: Renamed templates (file has new name, cluster has old name); applying to the wrong namespace; expired/incorrect kubeconfig; service accounts without workflowtemplate get permission.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/68d85c0640709725. Report an issue: GitHub.