{"record":{"id":"d6fd57f2b30ac1d6","repo":"apache/hadoop","slug":"invalid-uri-for-namenode-address-check-s-s-ha","errorCode":null,"errorMessage":"Invalid URI for NameNode address (check %s): %s has no authority.","messagePattern":"Invalid URI for NameNode address \\(check (.+?)\\): (.+?) has no authority\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSUtilClient.java","lineNumber":886,"sourceCode":"  }\n\n  public static InetSocketAddress getNNAddress(String address) {\n    return NetUtils.createSocketAddr(address,\n        HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);\n  }\n\n  public static InetSocketAddress getNNAddress(Configuration conf) {\n    URI filesystemURI = FileSystem.getDefaultUri(conf);\n    return getNNAddressCheckLogical(conf, filesystemURI);\n  }\n\n  /**\n   * @return address of file system\n   */\n  public static InetSocketAddress getNNAddress(URI filesystemURI) {\n    String authority = filesystemURI.getAuthority();\n    if (authority == null) {\n      throw new IllegalArgumentException(String.format(\n          \"Invalid URI for NameNode address (check %s): %s has no authority.\",\n          FileSystem.FS_DEFAULT_NAME_KEY, filesystemURI.toString()));\n    }\n    if (!HdfsConstants.HDFS_URI_SCHEME.equalsIgnoreCase(\n        filesystemURI.getScheme())) {\n      throw new IllegalArgumentException(String.format(\n          \"Invalid URI for NameNode address (check %s): \" +\n          \"%s is not of scheme '%s'.\", FileSystem.FS_DEFAULT_NAME_KEY,\n          filesystemURI.toString(), HdfsConstants.HDFS_URI_SCHEME));\n    }\n    return getNNAddress(authority);\n  }\n\n  /**\n   * Get the NN address from the URI. If the uri is logical, default address is\n   * returned. Otherwise return the DNS-resolved address of the URI.\n   *\n   * @param conf configuration","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSUtilClient.java#L868-L904","documentation":"DFSUtilClient.getNNAddress(URI) converts the default filesystem URI into a NameNode socket address and requires an authority (host:port or HA logical name) component. When the URI carries none — e.g., 'hdfs:///' or 'hdfs:' — it throws IllegalArgumentException('Invalid URI for NameNode address (check fs.defaultFS): ... has no authority.'), explicitly naming fs.defaultFS (FileSystem.FS_DEFAULT_NAME_KEY) as the property to correct.","triggerScenarios":"fs.defaultFS (or a URI handed directly to getNNAddress(URI)) lacking an authority: 'hdfs:///' written in core-site.xml, URIs built with URI.create(\"hdfs://\"), or property placeholders expanding to empty at load time.","commonSituations":"Incomplete or templated core-site.xml (missing host after hdfs://); cluster-agnostic test configurations using a bare scheme; configuration files shipped with placeholder values like ${nameNodeHost} that never get substituted.","solutions":["Set fs.defaultFS to a fully qualified authority: hdfs://nn1.example.com:8020 or the HA logical name hdfs://mycluster (with dfs.nameservices configured).","Validate the configuration at startup: assert FileSystem.getDefaultUri(conf).getAuthority() != null with a clear startup error.","If the code path must work without an NN, branch before calling getNNAddress(URI) rather than relying on the exception.","For HA, double-check dfs.nameservices and dfs.ha.namenodes.<id> match the logical authority you configured."],"exampleFix":"<!-- before: core-site.xml -->\n<property><name>fs.defaultFS</name><value>hdfs:///</value></property>\n\n<!-- after -->\n<property><name>fs.defaultFS</name><value>hdfs://mycluster</value></property>","handlingStrategy":"validation","validationCode":"URI defaultUri = FileSystem.getDefaultUri(conf);\nif (defaultUri.getAuthority() == null) {\n  throw new IllegalStateException(\n      \"fs.defaultFS must carry a NameNode authority, got: \" + defaultUri);\n}\nreturn DFSUtilClient.getNNAddress(defaultUri);","typeGuard":"boolean hasAuthority = uri.getAuthority() != null;","tryCatchPattern":"try {\n  return DFSUtilClient.getNNAddress(uri);\n} catch (IllegalArgumentException e) {\n  // config error: fail startup with an actionable message pointing at fs.defaultFS\n  throw new ConfigurationException(\"Fix fs.defaultFS (hdfs://host:port): \" + e.getMessage(), e);\n}","preventionTips":["Validate fs.defaultFS at application startup, not on first use deep in a job.","Use fully-qualified values (hdfs://nn:8020 or hdfs://logical-name) in templates; forbid 'hdfs:///' in config linting."],"tags":["hdfs","namenode","uri","configuration","argument-validation"],"backgroundTag":"invalid-endpoint-uri","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}