{"record":{"id":"72ec4b80541c4323","repo":"dgraph-io/dgraph","slug":"missing-or-empty-directory","errorCode":null,"errorMessage":"missing or empty directory","messagePattern":"missing or empty directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/file.go","lineNumber":101,"sourceCode":"\t\tif fi.IsDir() {\n\t\t\tmatchFn := func(f string) bool {\n\t\t\t\tfor _, e := range ext {\n\t\t\t\t\tif strings.HasSuffix(f, e) {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tlist = FindFilesFunc(str, matchFn)\n\t\t}\n\t}\n\n\treturn list\n}\n\n// ErrMissingDir is thrown by IsMissingOrEmptyDir if the given path is a\n// missing or empty directory.\nvar ErrMissingDir = errors.Errorf(\"missing or empty directory\")\n\n// IsMissingOrEmptyDir returns true if the path either does not exist\n// or is a directory that is empty.\nfunc IsMissingOrEmptyDir(path string) (err error) {\n\tvar fi os.FileInfo\n\tfi, err = os.Stat(path)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\terr = ErrMissingDir\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\n\tif !fi.IsDir() {\n\t\treturn\n\t}\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/x/file.go#L83-L119","documentation":"ErrMissingDir is the sentinel returned by IsMissingOrEmptyDir in x/file.go when the given path either does not exist or exists but is an empty directory. RunBulkLoader and other callers rely on it to detect that there is nothing to process.","triggerScenarios":"Calling IsMissingOrEmptyDir (directly or via RunBulkLoader) with a path that was never created, was deleted, or is an existing directory containing zero entries.","commonSituations":"dgraph bulk loader pointed at an empty/typo'd RDF directory; output of a previous stage written to a different path; volume mounted but empty because an init job failed.","solutions":["Point the flag at a directory that exists and contains input files (e.g. RDF gzips for the bulk loader)","Check for typos in the path and use an absolute path","Verify the upstream stage actually wrote files into the directory (ls -la)","Callers can check errors.Is(err, x.ErrMissingDir) to handle the empty case gracefully"],"exampleFix":"// before\nerr := bulk.Run(ctx) with --files=/data/rdfs (empty dir)\n// after\nls /data/rdfs/*.rdf.gz # ensure files exist, or fix the path\n--files=/data/rdfs","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(dir)\nif os.IsNotExist(err) || (err == nil && fi.IsDir() && dirEmpty(dir)) {\n    return fmt.Errorf(\"refusing to start: %s is missing or empty\", dir)\n}","typeGuard":null,"tryCatchPattern":"if err := bulk.Run(ctx); err != nil {\n    if errors.Is(err, x.ErrMissingDir) {\n        log.Fatalf(\"input directory missing or empty: populate it or fix the --files path\")\n    }\n    return err\n}","preventionTips":["Check the directory is non-empty before launching the bulk loader","Use absolute paths and verify with ls -la in your launch script","Ensure upstream jobs completed and wrote to the same path/mount","Handle errors.Is(err, x.ErrMissingDir) explicitly for graceful messaging"],"tags":["filesystem","bulk-loader","validation","directory"],"backgroundTag":"missing-or-empty-directory","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}