juicedata/juicefs · error · IllegalArgumentException
mkdirs path arg is null
Error message
mkdirs path arg is null
What it means
Thrown by mkdirs() when the path argument is null. The method checks access and then validates that f is non-null before normalizing the path, failing fast with IllegalArgumentException instead of a native error.
Source
Thrown at sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java:1856
@Override
public void setWorkingDirectory(Path newDir) {
workingDir = fixRelativePart(newDir);
checkPath(workingDir);
}
@Override
public Path getWorkingDirectory() {
return workingDir;
}
@Override
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
if (needCheckPermission() && !checkAncestorAccess(f, FsAction.WRITE, "mkdirs")) {
return superGroupFileSystem.mkdirs(f, permission);
}
statistics.incrementWriteOps(1);
if (f == null) {
throw new IllegalArgumentException("mkdirs path arg is null");
}
String path = normalizePath(f);
if ("/".equals(path))
return true;
int r = lib.jfs_mkdir(Thread.currentThread().getId(), handle, path, permission.toShort(), uMask.toShort());
if (r == 0 || r == EEXIST && !isFile(f)) {
return true;
} else if (r == ENOENT) {
Path parent = makeQualified(f).getParent();
if (parent != null) {
return mkdirs(parent, permission) && mkdirs(f, permission);
}
}
throw error(r, makeQualified(f).getParent());
}
@Override
public FileStatus getFileStatus(Path f) throws IOException {View on GitHub (pinned to c9a67b23e8)
Solutions
- Ensure the Path is non-null before calling mkdirs
- Provide a default directory when the config key is absent
- Validate inputs at job setup time rather than deep in the writer
- Use Objects.requireNonNull(path, ...) early to get a clear stack trace
Example fix
// before
fs.mkdirs(conf.get("output.dir"), perm); // may be null
// after
String dir = conf.get("output.dir", "/default/out");
fs.mkdirs(new Path(dir), perm); Defensive patterns
Strategy: validation
Validate before calling
if (f == null) throw new IllegalArgumentException("mkdirs path must not be null"); Type guard
boolean isNonNullPath(Path f) { return f != null; } Prevention
- Never pass config values straight into mkdirs without defaults
- Validate Path fields during job configuration phase
- Use Optional or explicit defaults for directory settings
When it happens
Trigger: fs.mkdirs(null, perm); deriving a path from an expression that evaluated to null (e.g. map.get("dir") returning null); passing an unset configuration value straight into mkdirs.
Common situations: Missing config key for an output directory; deserialized job parameters missing a field; template code where a Path variable was never assigned.
Related errors
- Invalid start or len parameter
- stream was closed
- arguments: " + off + " " + len
- position is negative
- Path already exists: " + f
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/a7cd2d1db1813b85.
Report an issue: GitHub.