{"record":{"id":"750b2e99976f02cf","repo":"argoproj/argo-workflows","slug":"unable-to-create-dir-for-file-s-w","errorCode":null,"errorMessage":"unable to create dir for file %s: %w","messagePattern":"unable to create dir for file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/azure/azure.go","lineNumber":177,"sourceCode":"\t\treturn fmt.Errorf(\"unable to remove attempted file download %s: %w\", path, err)\n\t}\n\n\t// It's a directory, so download all of the files.\n\terr = azblobDriver.DownloadDirectory(ctx, containerClient, artifact, path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to download directory %s: %w\", artifact.Azure.Blob, err)\n\t}\n\n\treturn nil\n}\n\n// DownloadFile downloads a single file from Azure Blob Storage\nfunc DownloadFile(ctx context.Context, containerClient *container.Client, blobName, path string) error {\n\tblobClient := containerClient.NewBlobClient(blobName)\n\n\terr := os.MkdirAll(filepath.Dir(path), 0755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create dir for file %s: %w\", path, err)\n\t}\n\toutFile, err := os.Create(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create file %s: %w\", path, err)\n\t}\n\tdefer func() {\n\t\tif closeErr := outFile.Close(); closeErr != nil {\n\t\t\tlogger := logging.RequireLoggerFromContext(ctx)\n\t\t\tlogger.WithFatal().WithError(closeErr).Warn(ctx, \"unable to close file\")\n\t\t}\n\t}()\n\n\t_, err = blobClient.DownloadFile(ctx, outFile, nil)\n\treturn err\n}\n\n// DownloadDirectory downloads all of the files starting with the named blob prefix into a local directory.\nfunc (azblobDriver *ArtifactDriver) DownloadDirectory(ctx context.Context, containerClient *container.Client, artifact *wfv1.Artifact, path string) error {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/azure/azure.go#L159-L195","documentation":"DownloadFile first ensures the parent directory of the destination path exists via os.MkdirAll before creating the file. This error means that MkdirAll failed, so the local filesystem could not be prepared for the blob download. It is a local FS error, not an Azure error.","triggerScenarios":"os.MkdirAll(filepath.Dir(path)) fails: parent path component is an existing regular file (ENOTDIR), read-only filesystem (EROFS), permission denied (EACCES), or path is empty/invalid on the target volume.","commonSituations":"Artifact path points inside a location already occupied by a file, emptyDir not mounted at the configured path, executor user lacks write access to the mount, downloading into a nested path where a file exists with the same name as an intermediate directory (common with directory artifacts).","solutions":["Fix the artifact `path` so its parent is a writable directory and no file occupies an intermediate component.","Ensure the volume is mounted at the path and is writable by the executor user.","Check the wrapped syscall in the message: ENOTDIR => a file blocks a dir component; EACCES => permissions; EROFS => read-only mount.","Pre-create the destination directory in the step's container image/entrypoint if needed.","For directory artifacts, use a clean empty target directory."],"exampleFix":"// before: path parent is a file\npath: /tmp/out/data/result.txt  # /tmp/out/data is a regular file\n// after: correct path\npath: /tmp/artifacts/result.txt","handlingStrategy":"validation","validationCode":"parent := filepath.Dir(path)\nst, err := os.Stat(parent)\nif err == nil && !st.IsDir() {\n\treturn fmt.Errorf(\"%s exists and is not a directory\", parent)\n}\n// verify write access\nif f, err := os.CreateTemp(parent, \".probe\"); err != nil { return err } else { f.Close(); os.Remove(f.Name()) }","typeGuard":"func ensureWritableDir(p string) error {\n\tif fi, err := os.Stat(p); err == nil && !fi.IsDir() {\n\t\treturn fmt.Errorf(\"file blocks directory %s\", p)\n\t}\n\treturn os.MkdirAll(p, 0o755)\n}","tryCatchPattern":null,"preventionTips":["Choose artifact paths whose parent is a clean writable directory","Avoid nested artifact paths that can collide with saved files","Mount a dedicated emptyDir/PVC for artifacts","Pre-create output directories in the container image"],"tags":["filesystem","local-disk","mkdir"],"backgroundTag":"mkdir-failed","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"}