argoproj/argo-workflows · error

failed to create folder path: %w

Error message

failed to create folder path: %w

What it means

`argo cp` calls os.MkdirAll to create the local output directory (rendered from the --path template) before downloading each artifact. This error wraps the OS failure, e.g. permission denied, a path component existing as a regular file, or an invalid path.

Source

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

			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 })
				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}")

View on GitHub (pinned to 35bff19146)

Solutions

  1. Choose an output directory you have write permission for, or fix permissions with chmod/chown.
  2. Inspect the wrapped OS error (errno) to identify the offending path component; remove/rename any file that occupies the path.
  3. Use --path with a unique-per-artifact pattern (include {nodeId}/{artifactName}) to avoid collisions.
  4. Check disk space / inode quota if errors indicate ENOSPC.

Example fix

// before
argo cp my-wf /var/lib/readonly/out
// after
argo cp my-wf ~/artifacts/out
Defensive patterns

Strategy: validation

Validate before calling

# pre-check writability of the target directory
dir="$2"
mkdir -p "$dir" || { echo "cannot create $dir"; exit 1; }
[ -w "$dir" ] || { echo "$dir not writable"; exit 1; }

Try / catch

if strings.Contains(err.Error(), "failed to create folder path") {
  return fmt.Errorf("check output dir permissions and that no file occupies the path: %w", err)
}

Prevention

When it happens

Trigger: The rendered outputPath cannot be created: parent directory is read-only, a file exists where a directory is needed (e.g. an artifact named like an existing file), outputDir contains invalid characters for the filesystem, or disk/quota issues.

Common situations: Writing into a protected directory (need sudo or a writable path); --path template rendering to a path that collides with an existing file; running in a read-only container; two artifacts resolving to the same path (one becomes a file, the next MkdirAll fails).

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


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