juicedata/juicefs · error · AccessControlException

User can not be null

Error message

User can not be null

What it means

Thrown by setOwner in the JuiceFS Hadoop client when permission checking is enabled and the caller invokes setOwner with a null username. The underlying guard rejects the call before any metadata change because an ownership change requires a target user; passing null usually means the caller only wanted to change the group, which this path does not support.

Source

Thrown at sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java:1947

  }

  @Override
  public void setPermission(Path p, FsPermission permission) throws IOException {
    if (needCheckPermission() && !checkOwner(p, "setPermission")) {
      superGroupFileSystem.setPermission(p, permission);
      return;
    }
    statistics.incrementWriteOps(1);
    int r = lib.jfs_chmod(Thread.currentThread().getId(), handle, normalizePath(p), permission.toShort());
    if (r != 0)
      throw error(r, p);
  }

  @Override
  public void setOwner(Path p, String username, String groupname) throws IOException {
    if (needCheckPermission()) {
      if (username == null) {
        throw new AccessControlException(
            "User can not be null");
      }
      if (!superuser.equals(username)) {
        throw new AccessControlException(
            "Only SuperUser can do setOwner Action, the current user is " + username);
      }
      superGroupFileSystem.setOwner(p, username, groupname);
      return;
    }
    statistics.incrementWriteOps(1);
    int r = lib.jfs_setOwner(Thread.currentThread().getId(), handle, normalizePath(p), username, groupname);
    if (r != 0)
      throw error(r, p);
  }

  @Override
  public void setTimes(Path p, long mtime, long atime) throws IOException {
    if (needCheckPermission() && !checkPathAccess(p, FsAction.WRITE, "setTimes")) {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Pass a non-null username to FileSystem.setOwner; to change only the group, still supply the current owner as the username
  2. Disable JuiceFS-side permission checking (juicefs.users/group or related config) so ownership enforcement is delegated to the filesystem
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java:1947 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/723c11aa854e0455. Report an issue: GitHub.