{"record":{"id":"cccfafb1b5934584","repo":"apache/seatunnel","slug":"get-hdfs-namenode-host-failed","errorCode":"GET_HDFS_NAMENODE_HOST_FAILED","errorMessage":"Get hdfs namenode host from table location [%s] failed,please check it","messagePattern":"Get hdfs namenode host from table location \\[(.+?)\\] failed,please check it","errorType":"error_code","errorClass":"HiveConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/source/config/HiveSourceConfig.java","lineNumber":269,"sourceCode":"            }\n            current = current.getCause();\n        }\n        return false;\n    }\n\n    private String parseFsDefaultName(Table table) {\n        String hdfsLocation = table.getSd().getLocation();\n        try {\n            URI uri = new URI(hdfsLocation);\n            String path = uri.getPath();\n            return hdfsLocation.replace(path, \"\");\n        } catch (URISyntaxException e) {\n            String errorMsg =\n                    String.format(\n                            \"Get hdfs namenode host from table location [%s] failed,\"\n                                    + \"please check it\",\n                            hdfsLocation);\n            throw new HiveConnectorException(\n                    HiveConnectorErrorCode.GET_HDFS_NAMENODE_HOST_FAILED, errorMsg, e);\n        }\n    }\n\n    private String parseHdfsPath(Table table) {\n        String hdfsLocation = table.getSd().getLocation();\n        try {\n            URI uri = new URI(hdfsLocation);\n            return uri.getPath();\n        } catch (URISyntaxException e) {\n            String errorMsg =\n                    String.format(\n                            \"Get hdfs namenode host from table location [%s] failed,\"\n                                    + \"please check it\",\n                            hdfsLocation);\n            throw new HiveConnectorException(\n                    HiveConnectorErrorCode.GET_HDFS_NAMENODE_HOST_FAILED, errorMsg, e);\n        }","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/source/config/HiveSourceConfig.java#L251-L287","documentation":"Thrown when the Hive table's storage location (table.getSd().getLocation()) cannot be parsed as a valid URI while extracting the HDFS namenode prefix (fs.default name). The connector builds a java.net.URI from the location string; a URISyntaxException means the location is malformed (illegal characters, spaces, unmatched brackets, etc.).","triggerScenarios":"HiveSourceConfig.parseFsDefaultName is invoked during source config parsing and `new URI(hdfsLocation)` throws URISyntaxException because the metastore-returned table location is not a valid URI (e.g. contains spaces, backslashes, illegal characters, or a malformed scheme like 'hdfs:/name' or missing host with port).","commonSituations":"Tables created manually in the metastore with a hand-typed LOCATION; locations copied from Windows paths with backslashes; locations with unencoded spaces or special characters; corrupted metastore entries after cluster migration.","solutions":["Run `new URI(location)` (or `DESCRIBE FORMATTED <table>`) on the location reported in the message and fix the illegal characters in the table's LOCATION","Correct the table location in Hive: `ALTER TABLE <db>.<table> SET LOCATION 'hdfs://namenode:8020/path/to/table'` (URL-encode any spaces/special chars)","Check the Hive metastore warehouse default location property (hive.metastore.warehouse.dir) for the same malformation","If the location string contains spaces, encode them (%20) rather than leaving raw characters"],"exampleFix":"// before (broken metastore location)\nLOCATION 'hdfs://namenode:8020/user/hive/warehouse/my table'\n// after\nALTER TABLE my_db.my_table SET LOCATION 'hdfs://namenode:8020/user/hive/warehouse/my%20table'","handlingStrategy":"validation","validationCode":"// Validate the table location URI before submitting the job\nString loc = table.getSd().getLocation();\ntry {\n    new java.net.URI(loc);\n} catch (java.net.URISyntaxException e) {\n    throw new IllegalArgumentException(\n        \"Invalid Hive table LOCATION URI: \" + loc + \" -> \" + e.getMessage());\n}","typeGuard":"boolean isValidUri(String s) {\n    try { new java.net.URI(s); return true; }\n    catch (java.net.URISyntaxException e) { return false; }\n}","tryCatchPattern":"try {\n    // ... start Hive source\n} catch (org.apache.seatunnel.connectors.seatunnel.hive.exception.HiveConnectorException e) {\n    if (\"GET_HDFS_NAMENODE_HOST_FAILED\".equals(e.getSeaTunnelErrorCode().getCode())) {\n        LOG.error(\"Fix the table LOCATION URI: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Always set table LOCATION via Hive DDL, never by editing the metastore by hand","Avoid spaces, backslashes, and unencoded reserved characters in HDFS paths","Run DESCRIBE FORMATTED to verify location syntax before configuring table_paths","Standardize on fully qualified hdfs://host:port paths in warehouse settings"],"tags":["hive","hdfs","uri-parsing","config"],"backgroundTag":"invalid-url-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}