{"record":{"id":"5fa2cad8de2c36eb","repo":"apache/hadoop","slug":"no-authentication-method-for-authmethod","errorCode":null,"errorMessage":"no authentication method for \" + authMethod","messagePattern":"no authentication method for \" \\+ authMethod","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java","lineNumber":1509,"sourceCode":"    public AuthMethod getAuthMethod() {\n      return authMethod;\n    }\n    \n    String getLoginAppName() {\n      if (loginAppName == null) {\n        throw new UnsupportedOperationException(\n            this + \" login authentication is not supported\");\n      }\n      return loginAppName;\n    }\n    \n    public static AuthenticationMethod valueOf(AuthMethod authMethod) {\n      for (AuthenticationMethod value : values()) {\n        if (value.getAuthMethod() == authMethod) {\n          return value;\n        }\n      }\n      throw new IllegalArgumentException(\n          \"no authentication method for \" + authMethod);\n    }\n  };\n\n  /**\n   * Create a proxy user using username of the effective user and the ugi of the\n   * real user.\n   * @param user user.\n   * @param realUser realUser.\n   * @return proxyUser ugi\n   */\n  @InterfaceAudience.Public\n  @InterfaceStability.Evolving\n  public static UserGroupInformation createProxyUser(String user,\n      UserGroupInformation realUser) {\n    if (user == null || user.isEmpty()) {\n      throw new IllegalArgumentException(\"Null user\");\n    }","sourceCodeStart":1491,"sourceCodeEnd":1527,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java#L1491-L1527","documentation":"AuthenticationMethod.valueOf(AuthMethod) maps a wire-level AuthMethod to an AuthenticationMethod by scanning enum values. When no constant matches (null AuthMethod, or one unknown to this Hadoop version), it throws IllegalArgumentException('no authentication method for X').","triggerScenarios":"Passing a null or unrecognized AuthMethod - typically produced by AuthMethod.valueOf(byte) decoding an auth code sent by a peer running a different Hadoop version, or by code constructing custom AuthMethods.","commonSituations":"Client and server on mismatched Hadoop versions exchanging new auth mechanism codes; hand-crafted SASL negotiation bytes; null AuthMethod leaking from a failed parse upstream.","solutions":["Align Hadoop versions (hadoop-common artifacts) across client and server","Validate the raw auth code against AuthMethod values before translating to AuthenticationMethod","Treat an unknown code as a protocol error and close the connection with a clear message"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"static boolean isKnownAuthMethod(AuthMethod m) {\n  for (UserGroupInformation.AuthenticationMethod am\n      : UserGroupInformation.AuthenticationMethod.values()) {\n    if (am.getAuthMethod() == m) return true;\n  }\n  return false;\n}","typeGuard":"static Optional<UserGroupInformation.AuthenticationMethod>\n    toAuthenticationMethod(AuthMethod m) {\n  for (UserGroupInformation.AuthenticationMethod am\n      : UserGroupInformation.AuthenticationMethod.values()) {\n    if (am.getAuthMethod() == m) return Optional.of(am);\n  }\n  return Optional.empty();\n}","tryCatchPattern":"try {\n  method = AuthenticationMethod.valueOf(authMethod);\n} catch (IllegalArgumentException e) {\n  throw new IOException(\"peer sent unknown auth method \" + authMethod\n      + \" - Hadoop version mismatch?\", e);\n}","preventionTips":["Pin matching hadoop-common versions across client and server","Validate decoded auth bytes against known AuthMethod values before translation","Treat unknown codes as protocol errors, not as bugs to catch late"],"tags":["hadoop","ugi","authentication-method","version-mismatch","rpc"],"backgroundTag":"protocol-version-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}