{"record":{"id":"a7cd2d1db1813b85","repo":"juicedata/juicefs","slug":"mkdirs-path-arg-is-null","errorCode":null,"errorMessage":"mkdirs path arg is null","messagePattern":"mkdirs path arg is null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java","lineNumber":1856,"sourceCode":"  @Override\n  public void setWorkingDirectory(Path newDir) {\n    workingDir = fixRelativePart(newDir);\n    checkPath(workingDir);\n  }\n\n  @Override\n  public Path getWorkingDirectory() {\n    return workingDir;\n  }\n\n  @Override\n  public boolean mkdirs(Path f, FsPermission permission) throws IOException {\n    if (needCheckPermission() && !checkAncestorAccess(f, FsAction.WRITE, \"mkdirs\")) {\n      return superGroupFileSystem.mkdirs(f, permission);\n    }\n    statistics.incrementWriteOps(1);\n    if (f == null) {\n      throw new IllegalArgumentException(\"mkdirs path arg is null\");\n    }\n    String path = normalizePath(f);\n    if (\"/\".equals(path))\n      return true;\n    int r = lib.jfs_mkdir(Thread.currentThread().getId(), handle, path, permission.toShort(), uMask.toShort());\n    if (r == 0 || r == EEXIST && !isFile(f)) {\n      return true;\n    } else if (r == ENOENT) {\n      Path parent = makeQualified(f).getParent();\n      if (parent != null) {\n        return mkdirs(parent, permission) && mkdirs(f, permission);\n      }\n    }\n    throw error(r, makeQualified(f).getParent());\n  }\n\n  @Override\n  public FileStatus getFileStatus(Path f) throws IOException {","sourceCodeStart":1838,"sourceCodeEnd":1874,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java#L1838-L1874","documentation":"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.","triggerScenarios":"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.","commonSituations":"Missing config key for an output directory; deserialized job parameters missing a field; template code where a Path variable was never assigned.","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"],"exampleFix":"// before\nfs.mkdirs(conf.get(\"output.dir\"), perm); // may be null\n// after\nString dir = conf.get(\"output.dir\", \"/default/out\");\nfs.mkdirs(new Path(dir), perm);","handlingStrategy":"validation","validationCode":"if (f == null) throw new IllegalArgumentException(\"mkdirs path must not be null\");","typeGuard":"boolean isNonNullPath(Path f) { return f != null; }","tryCatchPattern":null,"preventionTips":["Never pass config values straight into mkdirs without defaults","Validate Path fields during job configuration phase","Use Optional or explicit defaults for directory settings"],"tags":["java","hadoop","null-check"],"backgroundTag":"null-argument","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}