{"record":{"id":"b3110331961425c4","repo":"dgraph-io/dgraph","slug":"group-id-file-at-s-is-a-directory","errorCode":null,"errorMessage":"Group ID file at %s is a directory","messagePattern":"Group ID file at (.+?) is a directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/file.go","lineNumber":173,"sourceCode":"\tif _, err := f.WriteString(strconv.Itoa(int(group_id))); err != nil {\n\t\treturn err\n\t}\n\tif _, err := f.WriteString(\"\\n\"); err != nil {\n\t\treturn err\n\t}\n\treturn f.Close()\n}\n\n// ReadGroupIdFile reads the file at the given path and attempts to retrieve the\n// group ID stored in it.\nfunc ReadGroupIdFile(pdir string) (uint32, error) {\n\tpath := filepath.Join(pdir, GroupIdFileName)\n\tinfo, err := os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\treturn 0, nil\n\t}\n\tif info.IsDir() {\n\t\treturn 0, errors.Errorf(\"Group ID file at %s is a directory\", path)\n\t}\n\n\tcontents, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tgroupId, err := strconv.ParseUint(strings.TrimSpace(string(contents)), 0, 32)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint32(groupId), nil\n}\n","sourceCodeStart":155,"sourceCodeEnd":187,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/x/file.go#L155-L187","documentation":"ReadGroupIdFile reads the group_id file from a postings directory; it returns this error when the path exists but is a directory. A directory there means the data directory layout is corrupt or wrong, so the group ID cannot be determined and startup should abort.","triggerScenarios":"Calling ReadGroupIdFile on a postings directory where the entry named by GroupIdFileName is a directory instead of a regular file; called by runRestore and InitServerState when opening/restoring server state.","commonSituations":"Accidental directory creation at the group_id path (misconfigured volumes, wrong mount points, a recovery script that mkdir'd the path); partially copied or restored data directories; Docker/container mounts shadowing the file with a directory.","solutions":["Inspect the postings directory: if group_id is a directory, the data dir is corrupt — remove/replace it or restore from a good backup","Re-run the bulk loader or restore to regenerate a valid group_id file","Check for mount points or init scripts that created a directory named group_id and fix them","Never manually create the group_id path; let WriteGroupIdFile create it"],"exampleFix":"// before\n$ mkdir -p /data/postings/group_id  # wrong: creates a directory where the file belongs\n// after\n$ ls -la /data/postings\n$ rm -rf /data/postings/group_id   # remove the bogus directory\n$ dgraph zero && dgraph alpha --postings /data/postings  # loader/write creates the file","handlingStrategy":"validation","validationCode":"path := filepath.Join(pdir, \"group_id\")\ninfo, err := os.Stat(path)\nif err == nil && info.IsDir() {\n    return fmt.Errorf(\"%s is a directory; restore or re-run the bulk loader to fix the data directory\", path)\n}","typeGuard":"func groupIdFileOK(pdir string) bool {\n    info, err := os.Stat(filepath.Join(pdir, x.GroupIdFileName))\n    return err == nil && !info.IsDir()\n}","tryCatchPattern":"gid, err := x.ReadGroupIdFile(pdir)\nif err != nil && strings.Contains(err.Error(), \"is a directory\") {\n    return fmt.Errorf(\"postings dir %s corrupt at group_id; re-run bulk loader/restore\", pdir)\n}","preventionTips":["Never mkdir or mount anything at the group_id path inside postings directories","Verify data directory integrity after manual copies, restores, or container volume changes","Run the bulk loader/restore as the only mechanism that creates server state files","Monitor mounts so a volume never shadows an individual file with a directory"],"tags":["filesystem","group-id","corrupt-directory","startup"],"backgroundTag":"expected-file-is-directory","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}