argoproj/argo-workflows · error
error getting key for artifact: %w
Error message
error getting key for artifact: %w
What it means
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.
Source
Thrown at cmd/argo/commands/cp.go:99
for _, artifact := range artifactSearchResults {
outputPath := filepath.Join(outputDir, customPath)
nodeInfo := workflow.Status.Nodes.Find(func(n v1alpha1.NodeStatus) bool { return n.ID == artifact.NodeID })
if nodeInfo == nil {
return fmt.Errorf("could not get node status for node ID %s", artifact.NodeID)
}
outputPath = strings.Replace(outputPath, "{templateName}", wfutil.GetTemplateFromNode(*nodeInfo), 1)
outputPath = strings.Replace(outputPath, "{namespace}", namespace, 1)
outputPath = strings.Replace(outputPath, "{workflowName}", workflowName, 1)
outputPath = strings.Replace(outputPath, "{nodeId}", artifact.NodeID, 1)
outputPath = strings.Replace(outputPath, "{artifactName}", artifact.Name, 1)
err = os.MkdirAll(outputPath, os.ModePerm)
if err != nil {
return fmt.Errorf("failed to create folder path: %w", err)
}
key, err := artifact.GetKey()
if err != nil {
return fmt.Errorf("error getting key for artifact: %w", err)
}
err = getAndStoreArtifactData(ctx, namespace, workflowName, artifact.NodeID, artifact.Name, path.Base(key), outputPath, c, client.ArgoServerOpts)
if err != nil {
return fmt.Errorf("failed to get and store artifact data: %w", err)
}
}
return nil
},
}
command.Flags().StringVarP(&namespace, "namespace", "n", "", "namespace of workflow")
command.Flags().StringVar(&nodeID, "node-id", "", "id of node in workflow")
command.Flags().StringVar(&templateName, "template-name", "", "name of template in workflow")
command.Flags().StringVar(&artifactName, "artifact-name", "", "name of output artifact in workflow")
command.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}")
return command
}
func newArtifactHTTPClient(opts apiclient.ArgoServerOpts) (*http.Client, error) {View on GitHub (pinned to 35bff19146)
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.
Example fix
// before (copies all artifacts incl. failed) argo cp my-wf ./out // after argo cp my-wf ./out --artifact-name main-output
Defensive patterns
Strategy: validation
Validate before calling
# only target artifacts that saved successfully argo artifact list my-wf # review which artifacts exist before cp argo cp my-wf ./out --artifact-name main-output
Try / catch
// skip artifacts whose key can't be resolved and continue the loop
if strings.Contains(err.Error(), "error getting key for artifact") {
log.Printf("artifact %s has no storage key; skipping", artifact.Name)
continue
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Artifact driver connection validation failed: %v
- could not get node status for node ID %s
- failed to get and store artifact data: %w
- error appending filename %s to key of artifact %+v: err: %w
- failed to put file: %w
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/03ec30499e1e53fd.
Report an issue: GitHub.