{"record":{"id":"1d5b901a29ffa1d0","repo":"argoproj/argo-workflows","slug":"failed-to-create-directory-s-w","errorCode":null,"errorMessage":"failed to create directory %s: %w","messagePattern":"failed to create directory (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argoexec/commands/emissary.go","lineNumber":709,"sourceCode":"func saveArtifact(ctx context.Context, template *wfv1.Template, srcPath string) error {\n\tlogger := logging.RequireLoggerFromContext(ctx)\n\n\tif common.FindOverlappingVolume(template, srcPath) != nil {\n\t\tlogger.WithField(\"srcPath\", srcPath).Info(ctx, \"no need to save artifact - on overlapping volume\")\n\t\treturn nil\n\t}\n\tif _, err := os.Stat(srcPath); os.IsNotExist(err) { // might be optional, so we ignore\n\t\tlogger.WithField(\"srcPath\", srcPath).WithError(err).Warn(ctx, \"cannot save artifact\")\n\t\treturn nil\n\t}\n\tdstPath := filepath.Join(varRunArgo, \"/outputs/artifacts/\", strings.TrimSuffix(srcPath, \"/\")+\".tgz\")\n\tlogger.WithFields(logging.Fields{\n\t\t\"src\": srcPath,\n\t\t\"dst\": dstPath,\n\t}).Info(ctx, \"saving artifact\")\n\tz := filepath.Dir(dstPath)\n\tif err := os.MkdirAll(z, 0o755); err != nil { // chmod rwxr-xr-x\n\t\treturn fmt.Errorf(\"failed to create directory %s: %w\", z, err)\n\t}\n\tdst, err := os.Create(dstPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create destination %s: %w\", dstPath, err)\n\t}\n\tdefer func() { _ = dst.Close() }()\n\tif err = archive.TarGzToWriter(ctx, srcPath, gzip.DefaultCompression, dst); err != nil {\n\t\treturn fmt.Errorf(\"failed to tarball the output %s to %s: %w\", srcPath, dstPath, err)\n\t}\n\tif err = dst.Close(); err != nil {\n\t\treturn fmt.Errorf(\"failed to close %s: %w\", dstPath, err)\n\t}\n\treturn nil\n}\n\nfunc saveParameter(ctx context.Context, template *wfv1.Template, srcPath string) error {\n\tlogger := logging.RequireLoggerFromContext(ctx)\n","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argoexec/commands/emissary.go#L691-L727","documentation":"saveArtifact failed to create the parent directory of the artifact destination file under /var/run/argo/outputs/artifacts/ via os.MkdirAll(0o755). The artifact cannot be exported, so the step's output artifact will be missing. The wrapped error reveals the OS cause (usually permissions or disk space).","triggerScenarios":"os.MkdirAll(filepath.Dir(dstPath), 0o755) fails while saving an output artifact: /var/run/argo/outputs is not writable, disk is full, or a non-directory file exists at a path component of dstPath (path derived from the template's artifact path).","commonSituations":"Templates whose output artifact path collides with an existing file (e.g. path /var/run/argo/outputs/artifacts/foo where foo is a file); readOnlyRootFilesystem pods; ENOSPC; runAsUser without write access to /var/run/argo.","solutions":["Read the wrapped error: EEXIST/ENOTDIR means a file occupies a directory component of the artifact path — rename the template's artifact path.","Free node disk space if ENOSPC.","Grant the container write access to /var/run/argo (volume mount, correct runAsUser, not read-only).","Verify the artifact path in the template is a valid directory-form path (path.Dir is computed on it)."],"exampleFix":"// before: template artifact path that collides with a file\noutputs:\n  artifacts:\n  - name: out\n    path: /tmp/result        # /tmp/result is a FILE being both source base and dir component\n// after: use a dedicated output directory path\noutputs:\n  artifacts:\n  - name: out\n    path: /tmp/results/output.tgz","handlingStrategy":"validation","validationCode":"// validate template artifact paths before submit\nfor _, art := range tmpl.Outputs.Artifacts {\n    if strings.HasSuffix(art.Path, \"/\") || art.Path == \"\" {\n        return fmt.Errorf(\"artifact %q path %q invalid\", art.Name, art.Path)\n    }\n}\n// ensure /var/run/argo/outputs is writable in the image\n// os.MkdirAll(\"/var/run/argo/outputs/artifacts\", 0o755)","typeGuard":null,"tryCatchPattern":"if err := runStep(ctx); err != nil {\n    var wrapped error\n    if errors.Unwrap(err) != nil {\n        wrapped = errors.Unwrap(err)\n    }\n    if errors.Is(wrapped, os.ErrExist) || errors.Is(wrapped, syscall.ENOTDIR) {\n        return fixArtifactPathAndResubmit(ctx)\n    }\n    return err\n}","preventionTips":["Choose artifact output paths that don't collide with existing files","Test templates with argo lint and a dry run in a namespace with matching securityContext","Keep /var/run/argo on a writable emptyDir","Watch node ENOSPC alerts before large fan-out workflows"],"tags":["argo-workflows","argoexec","artifacts","filesystem"],"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"}