{"record":{"id":"4ae416becd222137","repo":"apache/hadoop","slug":"incomplete-hdfs-uri-no-host","errorCode":null,"errorMessage":"Incomplete HDFS URI, no host: {}","messagePattern":"Incomplete HDFS URI, no host: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/fs/Hdfs.java","lineNumber":88,"sourceCode":"\n  /**\n   * This constructor has the signature needed by\n   * {@link AbstractFileSystem#createFileSystem(URI, Configuration)}\n   * \n   * @param theUri which must be that of Hdfs\n   * @param conf configuration\n   * @throws IOException\n   */\n  Hdfs(final URI theUri, final Configuration conf) throws IOException, URISyntaxException {\n    super(theUri, HdfsConstants.HDFS_URI_SCHEME, true,\n        HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);\n\n    if (!theUri.getScheme().equalsIgnoreCase(HdfsConstants.HDFS_URI_SCHEME)) {\n      throw new IllegalArgumentException(\"Passed URI's scheme is not for Hdfs\");\n    }\n    String host = theUri.getHost();\n    if (host == null) {\n      throw new IOException(\"Incomplete HDFS URI, no host: \" + theUri);\n    }\n\n    this.dfs = new DFSClient(theUri, conf, getStatistics());\n  }\n\n  @Override\n  public int getUriDefaultPort() {\n    return HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT;\n  }\n\n  @Override\n  public HdfsDataOutputStream createInternal(Path f,\n      EnumSet<CreateFlag> createFlag, FsPermission absolutePermission,\n      int bufferSize, short replication, long blockSize, Progressable progress,\n      ChecksumOpt checksumOpt, boolean createParent) throws IOException {\n\n    final DFSOutputStream dfsos = dfs.primitiveCreate(getUriPath(f),\n      absolutePermission, createFlag, createParent, replication, blockSize,","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/fs/Hdfs.java#L70-L106","documentation":"After the scheme check, the Hdfs (AbstractFileSystem) constructor requires a hostname: URI.getHost() must be non-null or it throws IOException(\"Incomplete HDFS URI, no host: \" + theUri). Authority-less URIs such as hdfs:///path (empty authority) cannot be used with the FileContext-level Hdfs impl — an HA nameservice ID as the host is fine because it is still a host.","triggerScenarios":"FileContext.getFileContext(...) / create with a defaultFS or URI of 'hdfs:///' or 'hdfs:///user/x' (no authority); URIs built with URI.create(\"hdfs:///path\") or a port-only authority like 'hdfs://:8020'.","commonSituations":"fs.defaultFS configured without a host or nameservice; scripts stripping the authority when constructing paths; porting code from the FileSystem API (which resolves the default authority) to FileContext (which requires it in the URI).","solutions":["Set an explicit authority: hdfs://namenode:8020, or for HA hdfs://<nameservice-id>","Fix fs.defaultFS in core-site.xml to include the host or nameservice ID","Build URIs programmatically with new URI(\"hdfs\", host, path, null) instead of string concatenation that drops the //host part"],"exampleFix":"// before\nURI u = URI.create(\"hdfs:///user/me/in.txt\"); // no host\nFileContext fc = FileContext.getFileContext(u, conf);\n\n// after\nURI u = URI.create(\"hdfs://nn1.example.com:8020/user/me/in.txt\");\nFileContext fc = FileContext.getFileContext(u, conf);","handlingStrategy":"validation","validationCode":"URI u = URI.create(defaultFs);\nif (\"hdfs\".equalsIgnoreCase(u.getScheme()) && u.getHost() == null) {\n  throw new IllegalArgumentException(\n      \"fs.defaultFS lacks a host/nameservice: \" + defaultFs);\n}","typeGuard":"static boolean hasHdfsAuthority(URI u) {\n  return \"hdfs\".equalsIgnoreCase(u.getScheme()) && u.getHost() != null;\n}","tryCatchPattern":"try {\n  Hdfs h = (Hdfs) AbstractFileSystem.createFileSystem(u, conf);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Incomplete HDFS URI\")) {\n    // add hdfs://host:port or hdfs://nameservice-id\n  }\n}","preventionTips":["Always set fs.defaultFS with a host or HA nameservice ID","Build URIs with new URI(scheme, host, path, fragment) instead of string concat","Reject authority-less hdfs:/// URIs at configuration load time"],"tags":["hdfs","uri","configuration","filecontext","hadoop"],"backgroundTag":"uri-missing-host","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}