dgraph-io/dgraph · error
missing or empty directory
Error message
missing or empty directory
What it means
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.
Source
Thrown at x/file.go:101
if fi.IsDir() {
matchFn := func(f string) bool {
for _, e := range ext {
if strings.HasSuffix(f, e) {
return true
}
}
return false
}
list = FindFilesFunc(str, matchFn)
}
}
return list
}
// ErrMissingDir is thrown by IsMissingOrEmptyDir if the given path is a
// missing or empty directory.
var ErrMissingDir = errors.Errorf("missing or empty directory")
// IsMissingOrEmptyDir returns true if the path either does not exist
// or is a directory that is empty.
func IsMissingOrEmptyDir(path string) (err error) {
var fi os.FileInfo
fi, err = os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
err = ErrMissingDir
return
}
return
}
if !fi.IsDir() {
return
}
View on GitHub (pinned to 759e242be6)
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
Example fix
// before err := bulk.Run(ctx) with --files=/data/rdfs (empty dir) // after ls /data/rdfs/*.rdf.gz # ensure files exist, or fix the path --files=/data/rdfs
Defensive patterns
Strategy: validation
Validate before calling
fi, err := os.Stat(dir)
if os.IsNotExist(err) || (err == nil && fi.IsDir() && dirEmpty(dir)) {
return fmt.Errorf("refusing to start: %s is missing or empty", dir)
} Try / catch
if err := bulk.Run(ctx); err != nil {
if errors.Is(err, x.ErrMissingDir) {
log.Fatalf("input directory missing or empty: populate it or fix the --files path")
}
return err
} Prevention
- 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
When it happens
Trigger: Calling IsMissingOrEmptyDir (directly or via RunBulkLoader) with a path that was never created, was deleted, or is an existing directory containing zero entries.
Common situations: 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.
Related errors
- bulk output directory cannot be empty
- p directory does not exist for group [%d]: [%s]
- ID written to group_id file must be a positive number
- NQuad failed sanity check. Subject: %q, Predicate: %q, Objec
- empty variable name in function call
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/72ec4b80541c4323.
Report an issue: GitHub.