{"record":{"id":"97cd022a586478cc","repo":"argoproj/argo-workflows","slug":"unable-to-create-local-directory-s-w","errorCode":null,"errorMessage":"unable to create local directory %s: %w","messagePattern":"unable to create local directory (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/azure/azure.go","lineNumber":209,"sourceCode":"\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 {\n\tlogger := logging.RequireLoggerFromContext(ctx)\n\tlogger.WithField(\"endpoint\", artifact.Azure.Endpoint).\n\t\tWithField(\"container\", artifact.Azure.Container).\n\t\tWithField(\"blob\", artifact.Azure.Blob).\n\t\tInfo(ctx, \"Downloading directory from Azure Blob Storage\")\n\n\tfiles, err := azblobDriver.ListObjects(ctx, artifact)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to list blob %s in Azure Storage: %w\", artifact.Azure.Blob, err)\n\t}\n\n\terr = os.MkdirAll(path, 0755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create local directory %s: %w\", path, err)\n\t}\n\n\tfor _, file := range files {\n\t\t// For ADLS Gen 2 accounts, we'll see a file whose name matches the directory. Skip it.\n\t\tif file == artifact.Azure.Blob {\n\t\t\tcontinue\n\t\t}\n\n\t\trelKeyPath := strings.TrimPrefix(file, artifact.Azure.Blob)\n\t\tlocalPath := filepath.Join(path, relKeyPath)\n\n\t\terr = DownloadFile(ctx, containerClient, file, localPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to download file %s: %w\", localPath, err)\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/azure/azure.go#L191-L227","documentation":"After successfully listing the directory's blobs, DownloadDirectory creates the local destination directory with os.MkdirAll(path, 0755) before writing children. This error means creating that local directory failed — a purely local filesystem problem.","triggerScenarios":"os.MkdirAll(path) fails: an existing regular file occupies `path` (ENOTDIR/EEXIST semantics via intermediate), read-only volume, permission denied for the executor user, or ENOSPC/ENAMETOOLONG.","commonSituations":"Directory artifact path already exists as a file in the container, artifact path is on a read-only configMap/config mount, non-root executor cannot write to the given volume, deep blob prefixes making the local path too long.","solutions":["Ensure the artifact `path` is a clean writable directory location (does not exist as a file).","Fix volume permissions so the executor user can create the directory (securityContext fsGroup/runAsUser).","Check the wrapped syscall: EACCES => permissions, EROFS => read-only mount, ENAMETOOLONG => shorter prefix.","Pre-create the target directory in the image or a prior step.","Point directory artifacts at an emptyDir or dedicated PVC path."],"exampleFix":"// before: path exists as file\npath: /mnt/data    # regular file\n// after\npath: /mnt/data/dir","handlingStrategy":"validation","validationCode":"st, err := os.Lstat(path)\nif err == nil && !st.IsDir() {\n\treturn fmt.Errorf(\"%s exists as a file; choose a directory path\", path)\n}\nif err := os.MkdirAll(path, 0o755); err != nil { return err }","typeGuard":"func canCreateDir(p string) error {\n\tif fi, err := os.Lstat(p); err == nil && !fi.IsDir() {\n\t\treturn fmt.Errorf(\"file blocks dir %s\", p)\n\t}\n\treturn nil\n}","tryCatchPattern":null,"preventionTips":["Point directory artifacts at dedicated empty paths","Set securityContext fsGroup so the executor can write to volumes","Avoid read-only mounts as artifact destinations","Keep blob prefixes short to limit local path length"],"tags":["filesystem","mkdir","permissions"],"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"}