{"record":{"id":"fbccdddc301de5f2","repo":"apache/flink","slug":"hostname-originalhostname-starts-with-a-domai","errorCode":null,"errorMessage":"Hostname ${originalHostname} starts with a ${DOMAIN_SEPARATOR}","messagePattern":"Hostname (.+?) starts with a (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"warning","filePath":"flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/fs/hdfs/HadoopBlockLocation.java","lineNumber":117,"sourceCode":"     * @param originalHostname the original hostname, possibly an FQDN\n     * @return the stripped hostname without the domain suffix\n     */\n    private static String stripHostname(final String originalHostname) {\n\n        // Check if the hostname domains the domain separator character\n        final int index = originalHostname.indexOf(DOMAIN_SEPARATOR);\n        if (index == -1) {\n            return originalHostname;\n        }\n\n        // Make sure we are not stripping an IPv4 address\n        final Matcher matcher = IPV4_PATTERN.matcher(originalHostname);\n        if (matcher.matches()) {\n            return originalHostname;\n        }\n\n        if (index == 0) {\n            throw new IllegalStateException(\n                    \"Hostname \" + originalHostname + \" starts with a \" + DOMAIN_SEPARATOR);\n        }\n\n        return originalHostname.substring(0, index);\n    }\n}\n","sourceCodeStart":99,"sourceCodeEnd":124,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/fs/hdfs/HadoopBlockLocation.java#L99-L124","documentation":"HadoopBlockLocation.getHostName strips the first DNS label off hostnames that contain the domain separator ('.'), so 'host.example.com' becomes 'host'. Before stripping it verifies the string is not an IPv4 address and that the separator is not the first character; a leading '.' means the value is malformed for this operation, so an IllegalStateException is thrown.","triggerScenarios":"Calling getHost() on a HadoopBlockLocation whose underlying Hadoop BlockLocation reports a host string beginning with '.' (index == 0 for the DOMAIN_SEPARATOR).","commonSituations":"Odd or malformed block-location metadata returned by an HDFS NameNode or a non-standard Hadoop-compatible filesystem (e.g. some S3/mock connectors returning '.host' style names); custom Hadoop filesystem implementations with unusual location reporting.","solutions":["Fix the underlying filesystem/storage to return well-formed hostnames in block locations","Sanitize/normalize hostname strings before they reach block-location queries if you control the Hadoop filesystem shim","If the file layout does not need block locations, avoid getFileBlockLocations on this path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"String host = blockLocation.getHostName(); // only if you control the source\n// guard inputs to HadoopBlockLocation\nif (host == null || host.startsWith(\".\")) {\n    // reject/normalize malformed host before constructing block locations\n}","typeGuard":null,"tryCatchPattern":"try {\n    name = blockLocation.getHost();\n} catch (IllegalStateException e) {\n    // malformed hostname metadata; fall back to raw name if available or skip locality\n}","preventionTips":["Return well-formed hostnames from custom Hadoop filesystem implementations","Test block-location handling against your actual storage backend","Never construct hostnames with leading dots in test fixtures or shims"],"tags":["hdfs","hostname","block-location","malformed-data"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}