{"record":{"id":"57fe8a67ec9321c4","repo":"apache/hadoop","slug":"unrecognized-value-for-dfs-http-policy","errorCode":null,"errorMessage":"Unrecognized value '{}' for dfs.http.policy","messagePattern":"Unrecognized value '(.+?)' for dfs\\.http\\.policy","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java","lineNumber":1611,"sourceCode":"   * @return DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY if the key is not empty\n   *         else return defaultKey\n   */\n  public static String getSpnegoKeytabKey(Configuration conf, String defaultKey) {\n    String value = \n        conf.get(DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY);\n    return (value == null || value.isEmpty()) ?\n        defaultKey : DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY;\n  }\n\n  /**\n   * Get http policy.\n   */\n  public static HttpConfig.Policy getHttpPolicy(Configuration conf) {\n    String policyStr = conf.get(DFSConfigKeys.DFS_HTTP_POLICY_KEY,\n        DFSConfigKeys.DFS_HTTP_POLICY_DEFAULT);\n    HttpConfig.Policy policy = HttpConfig.Policy.fromString(policyStr);\n    if (policy == null) {\n      throw new HadoopIllegalArgumentException(\"Unrecognized value '\"\n          + policyStr + \"' for \" + DFSConfigKeys.DFS_HTTP_POLICY_KEY);\n    }\n\n    conf.set(DFSConfigKeys.DFS_HTTP_POLICY_KEY, policy.name());\n    return policy;\n  }\n\n  public static HttpServer2.Builder loadSslConfToHttpServerBuilder(HttpServer2.Builder builder,\n      Configuration sslConf) {\n    return builder\n        .needsClientAuth(\n            sslConf.getBoolean(DFS_CLIENT_HTTPS_NEED_AUTH_KEY,\n                DFS_CLIENT_HTTPS_NEED_AUTH_DEFAULT))\n        .keyPassword(getPassword(sslConf, DFS_SERVER_HTTPS_KEYPASSWORD_KEY))\n        .keyStore(sslConf.get(\"ssl.server.keystore.location\"),\n            getPassword(sslConf, DFS_SERVER_HTTPS_KEYSTORE_PASSWORD_KEY),\n            sslConf.get(\"ssl.server.keystore.type\", \"jks\"))\n        .trustStore(sslConf.get(\"ssl.server.truststore.location\"),","sourceCodeStart":1593,"sourceCodeEnd":1629,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java#L1593-L1629","documentation":"DFSUtil.getHttpPolicy reads dfs.http.policy (default HTTP_ONLY) and parses it with HttpConfig.Policy.fromString, which only accepts the enum names HTTP_ONLY, HTTPS_ONLY and HTTP_AND_HTTPS (case-insensitive). Any other string parses to null and the method throws HadoopIllegalArgumentException.","triggerScenarios":"dfs.http.policy set to anything outside {HTTP_ONLY, HTTPS_ONLY, HTTP_AND_HTTPS}, e.g. 'https', 'true', 'both', or a typo like 'HTTPS_ONLY '. Any component calling getHttpPolicy (NameNode/DataNode HTTP server setup) hits it at startup.","commonSituations":"Enabling HTTPS with an intuitive-but-invalid value such as 'https' or 'https_only'; copying examples from mismatched distro documentation; stray whitespace in the value.","solutions":["Set dfs.http.policy to a valid enum name, e.g. HTTPS_ONLY or HTTP_AND_HTTPS","Remove the property to fall back to the default HTTP_ONLY","Double-check spelling/whitespace and restart the service"],"exampleFix":"// before\n<property><name>dfs.http.policy</name><value>https</value></property>\n// after\n<property><name>dfs.http.policy</name><value>HTTPS_ONLY</value></property>","handlingStrategy":"validation","validationCode":"import org.apache.hadoop.http.HttpConfig;\n\nString policy = conf.get(\"dfs.http.policy\", \"HTTP_ONLY\");\nif (HttpConfig.Policy.fromString(policy) == null) {\n  throw new IllegalArgumentException(\"dfs.http.policy must be one of \"\n      + \"HTTP_ONLY, HTTPS_ONLY, HTTP_AND_HTTPS, got: '\" + policy + \"'\");\n}","typeGuard":"static boolean isValidHttpPolicy(String s) {\n  return HttpConfig.Policy.fromString(s) != null;\n}","tryCatchPattern":"catch (HadoopIllegalArgumentException e) during service startup; the message echoes the bad value - correct dfs.http.policy and restart rather than catching at runtime.","preventionTips":["Treat dfs.http.policy as an enum-typed value in config templates; lint configs before deploy","Smoke-test with `hdfs getconf -confKey dfs.http.policy` and compare against the three legal names"],"tags":["hdfs","configuration","http","https","tls","web-ui"],"backgroundTag":"invalid-enum-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}