{"record":{"id":"533507de336de182","repo":"apache/hadoop","slug":"invalid-host-specified","errorCode":null,"errorMessage":"Invalid host specified","messagePattern":"Invalid host specified","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java","lineNumber":109,"sourceCode":"\n  /**\n   * Get the default port for this FTPFileSystem.\n   *\n   * @return the default port\n   */\n  @Override\n  protected int getDefaultPort() {\n    return FTP.DEFAULT_PORT;\n  }\n\n  @Override\n  public void initialize(URI uri, Configuration conf) throws IOException { // get\n    super.initialize(uri, conf);\n    // get host information from uri (overrides info in conf)\n    String host = uri.getHost();\n    host = (host == null) ? conf.get(FS_FTP_HOST, null) : host;\n    if (host == null) {\n      throw new IOException(\"Invalid host specified\");\n    }\n    conf.set(FS_FTP_HOST, host);\n\n    // get port information from uri, (overrides info in conf)\n    int port = uri.getPort();\n    if(port == -1){\n      port = conf.getInt(FS_FTP_HOST_PORT, FTP.DEFAULT_PORT);\n    }\n    conf.setInt(FS_FTP_HOST_PORT, port);\n\n    // get user/password information from URI (overrides info in conf)\n    String userAndPassword = uri.getUserInfo();\n    if (userAndPassword == null) {\n      userAndPassword = (conf.get(FS_FTP_USER_PREFIX + host, null) + \":\" + conf\n          .get(FS_FTP_PASSWORD_PREFIX + host, null));\n    }\n    String[] userPasswdInfo = userAndPassword.split(\":\");\n    Preconditions.checkState(userPasswdInfo.length > 1,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java#L91-L127","documentation":"FTPFileSystem.initialize resolves the FTP host from the URI authority first, then falls back to the fs.ftp.host configuration key. If both are absent there is nothing to connect to, so FileSystem.get()/initialize fails immediately with this IOException.","triggerScenarios":"Using a URI whose authority has no host, e.g. new Path(\"ftp:///data/file\").getFileSystem(conf), or fs.defaultFS=ftp:/// , with no fs.ftp.host entry in the configuration; also ftp://:21/path where the authority parses to a null host.","commonSituations":"Job XML missing the fs.ftp.host property (typo or dropped during refactor); switching from absolute ftp://host/path URIs to relative paths; tool config built programmatically that never sets the key.","solutions":["Put the host in the URI: ftp://ftp.example.com:21/path (optionally ftp://user:pass@ftp.example.com/path)","Or set conf.set(\"fs.ftp.host\", \"ftp.example.com\") (plus optional fs.ftp.host.port, default 21) before FileSystem.get","When building FTP URIs dynamically, assert uri.getHost() != null before use"],"exampleFix":"// before\nConfiguration conf = new Configuration();\nFileSystem fs = new Path(\"ftp:///data/file\").getFileSystem(conf);\n// IOException: Invalid host specified\n\n// after\nConfiguration conf = new Configuration();\nconf.set(\"fs.ftp.host\", \"ftp.example.com\");\nconf.setInt(\"fs.ftp.host.port\", 21);\nFileSystem fs = new Path(\"ftp:///data/file\").getFileSystem(conf);","handlingStrategy":"validation","validationCode":"URI u = URI.create(\"ftp://\" + host + \":\" + port + path);\nif (u.getHost() == null) {\n  throw new IllegalArgumentException(\"FTP URI has no host: \" + u);\n}\n// or pre-seed config: conf.set(\"fs.ftp.host\", host);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set fs.ftp.host (and fs.ftp.host.port if not 21) in job configuration when using relative ftp paths","Assert uri.getHost() != null whenever FTP URIs are assembled from parts","Smoke-test FileSystem.get(path.toUri(), conf) at job start to fail before work begins"],"tags":["ftp","configuration","uri","missing-host"],"backgroundTag":"missing-host-configuration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}