{"record":{"id":"c920e56486b5565c","repo":"argoproj/argo-workflows","slug":"failed-to-get-workflow-w","errorCode":null,"errorMessage":"failed to get workflow: %w","messagePattern":"failed to get workflow: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/cp.go","lineNumber":66,"sourceCode":"\t\t\t}\n\t\t\tworkflowName := args[0]\n\t\t\toutputDir := args[1]\n\n\t\t\tctx := cmd.Context()\n\t\t\tctx, apiClient, err := client.NewAPIClient(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tserviceClient := apiClient.NewWorkflowServiceClient(ctx)\n\t\t\tif len(namespace) == 0 {\n\t\t\t\tnamespace = client.Namespace(ctx)\n\t\t\t}\n\t\t\tworkflow, err := serviceClient.GetWorkflow(ctx, &workflowpkg.WorkflowGetRequest{\n\t\t\t\tName:      workflowName,\n\t\t\t\tNamespace: namespace,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to get workflow: %w\", err)\n\t\t\t}\n\n\t\t\tworkflowName = workflow.Name\n\t\t\tartifactSearchQuery := v1alpha1.ArtifactSearchQuery{\n\t\t\t\tArtifactName: artifactName,\n\t\t\t\tTemplateName: templateName,\n\t\t\t\tNodeId:       nodeID,\n\t\t\t}\n\t\t\tartifactSearchResults := workflow.SearchArtifacts(&artifactSearchQuery)\n\n\t\t\tc, err := newArtifactHTTPClient(client.ArgoServerOpts)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tfor _, artifact := range artifactSearchResults {\n\t\t\t\toutputPath := filepath.Join(outputDir, customPath)\n\t\t\t\tnodeInfo := workflow.Status.Nodes.Find(func(n v1alpha1.NodeStatus) bool { return n.ID == artifact.NodeID })","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/cp.go#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the workflow exists: `argo list -n <namespace> | grep <name>`.","Pass `--namespace` (or `-n`) explicitly to match where the workflow runs.","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`).","If RBAC-related, request workflow-get permissions in that namespace for your service account/token."],"exampleFix":"// before (no namespace, default namespace wrong)\nargo cp my-wf ./out\n// after\nargo cp my-wf ./out --namespace my-namespace","handlingStrategy":"try-catch","validationCode":"// confirm the workflow exists before copying\nargo get my-wf -n my-ns >/dev/null 2>&1 || { echo \"workflow not found\"; exit 1; }","typeGuard":null,"tryCatchPattern":"// in Go: distinguish not-found from transient errors\nif err := cmd.Run(); err != nil {\n  if strings.Contains(err.Error(), \"not found\") {\n    return fmt.Errorf(\"workflow %q does not exist in namespace %q\", name, ns)\n  }\n  return err // auth/network: inspect wrapped cause\n}","preventionTips":["Always pass --namespace explicitly in scripts.","Verify ARGO_SERVER/ARGO_TOKEN env are set and current in CI.","Check `argo list` works before scripted cp operations."],"tags":["cli","kubernetes","api","network"],"backgroundTag":"resource-not-found","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}