{"record":{"id":"4ddb6b95224ac95b","repo":"dgraph-io/dgraph","slug":"create-path-failed-to-create-path-s-got-error","errorCode":null,"errorMessage":"Create path failed to create path %s, got error: %v","messagePattern":"Create path failed to create path (.+?), got error: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/backup_handler.go","lineNumber":189,"sourceCode":"func (h *fileHandler) FileExists(path string) bool      { return pathExist(h.JoinPath(path)) }\nfunc (h *fileHandler) Read(path string) ([]byte, error) { return os.ReadFile(h.JoinPath(path)) }\n\nfunc (h *fileHandler) JoinPath(path string) string {\n\treturn filepath.Join(h.rootDir, h.prefix, cleanRelPath(path))\n}\nfunc (h *fileHandler) Stream(path string) (io.ReadCloser, error) {\n\treturn os.Open(h.JoinPath(path))\n}\nfunc (h *fileHandler) ListPaths(path string) []string {\n\tpath = h.JoinPath(path)\n\treturn x.WalkPathFunc(path, func(path string, isDis bool) bool {\n\t\treturn true\n\t})\n}\nfunc (h *fileHandler) CreateDir(path string) error {\n\tpath = h.JoinPath(path)\n\tif err := os.MkdirAll(path, 0755); err != nil {\n\t\treturn errors.Errorf(\"Create path failed to create path %s, got error: %v\", path, err)\n\t}\n\treturn nil\n}\n\ntype fileSyncer struct {\n\tfp *os.File\n}\n\nfunc (fs *fileSyncer) Write(p []byte) (n int, err error) { return fs.fp.Write(p) }\nfunc (fs *fileSyncer) Close() error {\n\tif err := fs.fp.Sync(); err != nil {\n\t\treturn errors.Wrapf(err, \"while syncing file: %s\", fs.fp.Name())\n\t}\n\terr := fs.fp.Close()\n\treturn errors.Wrapf(err, \"while closing file: %s\", fs.fp.Name())\n}\n\nfunc (h *fileHandler) CreateFile(path string) (io.WriteCloser, error) {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/backup_handler.go#L171-L207","documentation":"fileHandler.CreateDir wraps os.MkdirAll failures with this message, embedding the resolved path and the OS error. It means the local-filesystem handler could not create (recursively) the directory needed for a backup or export operation. The message deliberately includes both the path and the underlying cause for diagnosis.","triggerScenarios":"os.MkdirAll(path, 0755) fails: parent directory not writable, path component is a file, permission denied, disk full, or read-only filesystem on the JoinPath-resolved path under the handler's rootDir.","commonSituations":"Worker lacks write permission on the backup root; a file exists where a directory is expected; container running with read-only rootfs; NFS stale-handle issues on network mounts; path length limits exceeded.","solutions":["Read the wrapped %v cause to see the exact errno (EACCES, ENOSPC, ENOTDIR, EROFS).","Verify/fix permissions: chown/chmod the parent directory for the worker user.","Remove or rename any non-directory file occupying the target path.","Check disk space and mount status (df -h, mount) for ENOSPC or ro filesystems.","If path is outside the intended root, fix the URI/rootDir configuration."],"exampleFix":"// before\nif err := os.MkdirAll(path, 0755); err != nil {\n    return errors.Errorf(\"Create path failed to create path %s, got error: %v\", path, err)\n}\n// after\nif err := os.MkdirAll(path, 0755); err != nil {\n    if errors.Is(err, os.ErrPermission) {\n        return errors.Errorf(\"Create path failed to create path %s: permission denied; check worker user owns parent\", path)\n    }\n    return errors.Errorf(\"Create path failed to create path %s, got error: %v\", path, err)\n}","handlingStrategy":"validation","validationCode":"root := handlerRootDir()\nif info, err := os.Stat(root); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"backup root %s missing or not a directory\", root)\n}\nif err := unix.Access(root, unix.W_OK); err != nil {\n    return fmt.Errorf(\"backup root %s not writable: %v\", root, err)\n}","typeGuard":"func canCreateDir(root string) bool {\n    f, err := os.CreateTemp(root, \".writetest*\")\n    if err != nil { return false }\n    f.Close()\n    os.Remove(f.Name())\n    return true\n}","tryCatchPattern":"if err := handler.CreateDir(dir); err != nil {\n    var pe *os.PathError\n    if errors.As(err, &pe) {\n        log.Printf(\"mkdir failed path=%s op=%s cause=%v\", pe.Path, pe.Op, pe.Err)\n    }\n    return err\n}","preventionTips":["Provision and chown the backup root during deployment.","Avoid nesting backup dirs under mount points that may go read-only.","Test directory creation in health checks.","Monitor free space so backup roots never sit on full disks."],"tags":["filesystem","mkdir","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}