{"record":{"id":"03ec30499e1e53fd","repo":"argoproj/argo-workflows","slug":"error-getting-key-for-artifact-w","errorCode":null,"errorMessage":"error getting key for artifact: %w","messagePattern":"error getting key for artifact: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/cp.go","lineNumber":99,"sourceCode":"\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 })\n\t\t\t\tif nodeInfo == nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not get node status for node ID %s\", artifact.NodeID)\n\t\t\t\t}\n\t\t\t\toutputPath = strings.Replace(outputPath, \"{templateName}\", wfutil.GetTemplateFromNode(*nodeInfo), 1)\n\t\t\t\toutputPath = strings.Replace(outputPath, \"{namespace}\", namespace, 1)\n\t\t\t\toutputPath = strings.Replace(outputPath, \"{workflowName}\", workflowName, 1)\n\t\t\t\toutputPath = strings.Replace(outputPath, \"{nodeId}\", artifact.NodeID, 1)\n\t\t\t\toutputPath = strings.Replace(outputPath, \"{artifactName}\", artifact.Name, 1)\n\t\t\t\terr = os.MkdirAll(outputPath, os.ModePerm)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to create folder path: %w\", err)\n\t\t\t\t}\n\t\t\t\tkey, err := artifact.GetKey()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error getting key for artifact: %w\", err)\n\t\t\t\t}\n\t\t\t\terr = getAndStoreArtifactData(ctx, namespace, workflowName, artifact.NodeID, artifact.Name, path.Base(key), outputPath, c, client.ArgoServerOpts)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to get and store artifact data: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\tcommand.Flags().StringVarP(&namespace, \"namespace\", \"n\", \"\", \"namespace of workflow\")\n\tcommand.Flags().StringVar(&nodeID, \"node-id\", \"\", \"id of node in workflow\")\n\tcommand.Flags().StringVar(&templateName, \"template-name\", \"\", \"name of template in workflow\")\n\tcommand.Flags().StringVar(&artifactName, \"artifact-name\", \"\", \"name of output artifact in workflow\")\n\tcommand.Flags().StringVar(&customPath, \"path\", \"{namespace}/{workflowName}/{nodeId}/outputs/{artifactName}\", \"use variables {workflowName}, {nodeId}, {templateName}, {artifactName}, and {namespace} to create a customized path to store the artifacts; example: {workflowName}/{templateName}/{artifactName}\")\n\treturn command\n}\n\nfunc newArtifactHTTPClient(opts apiclient.ArgoServerOpts) (*http.Client, error) {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/cp.go#L81-L117","documentation":"Raised in argo cp while resolving where to write a downloaded artifact: constructing or locating the storage key for the artifact failed, wrapped with the underlying cause. It aborts copying that artifact to the output path.","triggerScenarios":"An artifact in the search results lacks the metadata needed to compute its key (missing ArtifactLocation fields or key data), e.g. an artifact that was never successfully stored or has an empty/invalid key reference in status.","commonSituations":"Workflow status recording artifacts whose backing storage info is incomplete; failed artifact saves left behind as failed/deleted entries in node outputs; corrupted or hand-edited workflow status.","solutions":["Skip or filter failed artifacts by narrowing the query: `--artifact-name <specific>` or `--node-id <node>`.","Check the workflow node status (`argo get <wf>`) to see whether the artifact actually saved successfully.","Re-run the failing node to regenerate a valid artifact.","If reproducible on healthy workflows, upgrade and/or report a bug with the wrapped inner error."],"exampleFix":"// before (copies all artifacts incl. failed)\nargo cp my-wf ./out\n// after\nargo cp my-wf ./out --artifact-name main-output","handlingStrategy":"validation","validationCode":"# only target artifacts that saved successfully\nargo artifact list my-wf   # review which artifacts exist before cp\nargo cp my-wf ./out --artifact-name main-output","typeGuard":null,"tryCatchPattern":"// skip artifacts whose key can't be resolved and continue the loop\nif strings.Contains(err.Error(), \"error getting key for artifact\") {\n  log.Printf(\"artifact %s has no storage key; skipping\", artifact.Name)\n  continue\n}","preventionTips":["Filter with --artifact-name/--node-id instead of copying all artifacts.","Check node phase (Succeeded) for artifacts before copying.","Re-run failed nodes to regenerate missing artifact records."],"tags":["cli","artifacts","storage"],"backgroundTag":"artifact-key-missing","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"}