argoproj/argo-workflows · error

failed to get workflow: %w

Error message

failed to get workflow: %w

What it means

The `argo cp` command failed to fetch the Workflow object via the WorkflowGetRequest gRPC/HTTP call before searching its artifacts. The underlying error (auth, network, or API error) is wrapped and returned.

Source

Thrown at cmd/argo/commands/cp.go:66

			}
			workflowName := args[0]
			outputDir := args[1]

			ctx := cmd.Context()
			ctx, apiClient, err := client.NewAPIClient(ctx)
			if err != nil {
				return err
			}
			serviceClient := apiClient.NewWorkflowServiceClient(ctx)
			if len(namespace) == 0 {
				namespace = client.Namespace(ctx)
			}
			workflow, err := serviceClient.GetWorkflow(ctx, &workflowpkg.WorkflowGetRequest{
				Name:      workflowName,
				Namespace: namespace,
			})
			if err != nil {
				return fmt.Errorf("failed to get workflow: %w", err)
			}

			workflowName = workflow.Name
			artifactSearchQuery := v1alpha1.ArtifactSearchQuery{
				ArtifactName: artifactName,
				TemplateName: templateName,
				NodeId:       nodeID,
			}
			artifactSearchResults := workflow.SearchArtifacts(&artifactSearchQuery)

			c, err := newArtifactHTTPClient(client.ArgoServerOpts)
			if err != nil {
				return err
			}

			for _, artifact := range artifactSearchResults {
				outputPath := filepath.Join(outputDir, customPath)
				nodeInfo := workflow.Status.Nodes.Find(func(n v1alpha1.NodeStatus) bool { return n.ID == artifact.NodeID })

View on GitHub (pinned to 35bff19146)

Solutions

  1. Verify the workflow exists: `argo list -n <namespace> | grep <name>`.
  2. Pass `--namespace` (or `-n`) explicitly to match where the workflow runs.
  3. Check server connectivity/config: `argo list` works? Verify ARGO_SERVER, ARGO_TOKEN, and port-forward (`kubectl -n argo port-forward svc/argo-server 2746:2746`).
  4. If RBAC-related, request workflow-get permissions in that namespace for your service account/token.

Example fix

// before (no namespace, default namespace wrong)
argo cp my-wf ./out
// after
argo cp my-wf ./out --namespace my-namespace
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm the workflow exists before copying
argo get my-wf -n my-ns >/dev/null 2>&1 || { echo "workflow not found"; exit 1; }

Try / catch

// in Go: distinguish not-found from transient errors
if err := cmd.Run(); err != nil {
  if strings.Contains(err.Error(), "not found") {
    return fmt.Errorf("workflow %q does not exist in namespace %q", name, ns)
  }
  return err // auth/network: inspect wrapped cause
}

Prevention

When it happens

Trigger: Running `argo cp <name> <dir>` when the workflow does not exist in the namespace, the namespace flag is wrong, the argo server is unreachable or misconfigured (wrong URL/port/token), or RBAC denies workflow get in the namespace.

Common situations: Typo in the workflow name; wrong `--namespace` or ARGO_NAMESPACE; server host env vars (ARGO_SERVER/ARGO_HTTP1/ARGO_TOKEN) pointing at the wrong cluster or expired token; workflow already archived/GC'd from the live namespace.

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/c920e56486b5565c. Report an issue: GitHub.