apache/iceberg · warning

Hadoop user is null, defaulting to user.name

Error message

Hadoop user is null, defaulting to user.name

What it means

Companion fallback of currentUser(): after a failed UGI lookup, the short username is still null, so the code logs this warning and returns the JVM 'user.name' system property instead. Identity comes from the OS/JVM rather than Hadoop, which may not match the intended metastore user.

Solutions

  1. Pass -Duser.name=<hadoop-user> as a JVM argument to align the fallback identity
  2. Fix the root cause: put Hadoop config on the classpath or initialize UGI so getCurrentUser works
  3. Verify which user HMS sees (e.g. in metastore logs) and align configuration accordingly

Example fix

// before
java -jar app.jar
// after
java -Duser.name=iceberg_svc -jar app.jar
Defensive patterns

Strategy: validation

Validate before calling

String user = System.getProperty("user.name"); if (user == null || user.equals("root")) { /* fix -Duser.name before running */ }

Prevention

When it happens

Trigger: UserGroupInformation.getCurrentUser() throws IOException AND the caught path leaves username null, so the else branch reads System.getProperty("user.name").

Common situations: Containers where the OS user (e.g. 'root' or a UID) differs from the Kerberos/Hadoop identity expected by HMS; entitlement or ownership checks then record the wrong user.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/ee8b4050d27d7a5d. Report an issue: GitHub.

Appendix: source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveHadoopUtil.java:43

public class HiveHadoopUtil {

  private static final Logger LOG = LoggerFactory.getLogger(HiveHadoopUtil.class);

  private HiveHadoopUtil() {}

  public static String currentUser() {
    String username = null;
    try {
      username = UserGroupInformation.getCurrentUser().getShortUserName();
    } catch (IOException e) {
      LOG.warn("Failed to get Hadoop user", e);
    }

    if (username != null) {
      return username;
    } else {
      LOG.warn("Hadoop user is null, defaulting to user.name");
      return System.getProperty("user.name");
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)