{"record":{"id":"46bb35ad668f97b0","repo":"argoproj/argo-workflows","slug":"failed-to-create-folder-path-w","errorCode":null,"errorMessage":"failed to create folder path: %w","messagePattern":"failed to create folder path: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/cp.go","lineNumber":95,"sourceCode":"\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 })\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}\")","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/cp.go#L77-L113","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Choose an output directory you have write permission for, or fix permissions with chmod/chown.","Inspect the wrapped OS error (errno) to identify the offending path component; remove/rename any file that occupies the path.","Use --path with a unique-per-artifact pattern (include {nodeId}/{artifactName}) to avoid collisions.","Check disk space / inode quota if errors indicate ENOSPC."],"exampleFix":"// before\nargo cp my-wf /var/lib/readonly/out\n// after\nargo cp my-wf ~/artifacts/out","handlingStrategy":"validation","validationCode":"# pre-check writability of the target directory\ndir=\"$2\"\nmkdir -p \"$dir\" || { echo \"cannot create $dir\"; exit 1; }\n[ -w \"$dir\" ] || { echo \"$dir not writable\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"failed to create folder path\") {\n  return fmt.Errorf(\"check output dir permissions and that no file occupies the path: %w\", err)\n}","preventionTips":["Pre-create the output directory and verify write permission before running.","Include {nodeId}/{artifactName} in --path so per-artifact paths never collide.","Never point --path at a location containing an existing regular file with the same name."],"tags":["cli","filesystem","permissions"],"backgroundTag":"mkdir-permission-denied","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"}