apache/hadoop · error · IllegalArgumentException

Null user

Error message

Null user

What it means

UGI.createRemoteUser builds an uncredentialed identity for RPC authorization; a null or empty user name is meaningless and rejected with IllegalArgumentException('Null user') before any Subject is built.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java:1454

   */
  @InterfaceAudience.Public
  @InterfaceStability.Evolving
  public static UserGroupInformation createRemoteUser(String user) {
    return createRemoteUser(user, AuthMethod.SIMPLE);
  }
  
  /**
   * Create a user from a login name. It is intended to be used for remote
   * users in RPC, since it won't have any credentials.
   * @param user the full user principal name, must not be empty or null
   * @param authMethod authMethod.
   * @return the UserGroupInformation for the remote user.
   */
  @InterfaceAudience.Public
  @InterfaceStability.Evolving
  public static UserGroupInformation createRemoteUser(String user, AuthMethod authMethod) {
    if (user == null || user.isEmpty()) {
      throw new IllegalArgumentException("Null user");
    }
    Subject subject = new Subject();
    subject.getPrincipals().add(new User(user));
    UserGroupInformation result = new UserGroupInformation(subject);
    result.setAuthenticationMethod(authMethod);
    return result;
  }

  /**
   * existing types of authentications' methods
   */
  @InterfaceAudience.Public
  @InterfaceStability.Evolving
  public enum AuthenticationMethod {
    // currently we support only one auth per method, but eventually a 
    // subtype is needed to differentiate, ex. if digest is token or ldap
    SIMPLE(AuthMethod.SIMPLE,
        HadoopConfiguration.SIMPLE_CONFIG_NAME),

View on GitHub (pinned to 2add963021)

Solutions

  1. Validate the remote user name at your trust boundary (non-null, non-empty after trim) before calling createRemoteUser
  2. If the protocol defines an anonymous identity, map missing names to it explicitly
  3. Fail the request early with a 400/403 rather than letting the exception escape mid-RPC

Example fix

// before
UserGroupInformation ugi =
    UserGroupInformation.createRemoteUser(headerUser, AuthMethod.TOKEN);
// after
if (headerUser == null || headerUser.trim().isEmpty()) {
  throw new IllegalArgumentException("missing remote user");
}
UserGroupInformation ugi =
    UserGroupInformation.createRemoteUser(headerUser.trim(), AuthMethod.TOKEN);
Defensive patterns

Strategy: validation

Validate before calling

if (user == null || user.trim().isEmpty()) {
  throw new IllegalArgumentException("remote user name is required");
}
UserGroupInformation.createRemoteUser(user.trim(), authMethod);

Type guard

static boolean isValidRemoteUser(String user) {
  return user != null && !user.trim().isEmpty();
}

Prevention

When it happens

Trigger: createRemoteUser(null) or createRemoteUser("") - usually unvalidated input flowing from an RPC layer, HTTP header/parameter, or deserialized payload.

Common situations: Custom auth filters reading a missing proxy-user header; null effective user from a serializer; test harnesses passing empty strings.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/36df413752125be6. Report an issue: GitHub.