{"record":{"id":"d2403d2ad64b32da","repo":"apache/hadoop","slug":"invalid-hostname-provided-s","errorCode":null,"errorMessage":"Invalid hostname provided '%s'","messagePattern":"Invalid hostname provided '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/NfsExports.java","lineNumber":406,"sourceCode":"      if (LOG.isDebugEnabled()) {\n        LOG.debug(\"Using CIDR match for '\" + host + \"' and \" + privilege);\n      }\n      String[] pair = host.split(\"/\");\n      return new CIDRMatch(privilege,\n          new SubnetUtils(pair[0], pair[1]).getInfo());\n    } else if (host.contains(\"*\") || host.contains(\"?\") || host.contains(\"[\")\n        || host.contains(\"]\") || host.contains(\"(\") || host.contains(\")\")) {\n      if (LOG.isDebugEnabled()) {\n        LOG.debug(\"Using Regex match for '\" + host + \"' and \" + privilege);\n      }\n      return new RegexMatch(privilege, host);\n    } else if (HOSTNAME_FORMAT.matcher(host).matches()) {\n      if (LOG.isDebugEnabled()) {\n        LOG.debug(\"Using exact match for '\" + host + \"' and \" + privilege);\n      }\n      return new ExactMatch(privilege, host);\n    } else {\n      throw new IllegalArgumentException(\"Invalid hostname provided '\" + host\n          + \"'\");\n    }\n  }\n}\n","sourceCodeStart":388,"sourceCodeEnd":411,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/NfsExports.java#L388-L411","documentation":"After tokenizing, NfsExports classifies the lowercased host token: '*' becomes an anonymous match, CIDR short (d.d.d.d/n) or long (d.d.d.d/d.d.d.d) forms, a regex match if the token contains * ? [ ] ( ), or an exact match if it is an RFC-1123 hostname (labels of 1-63 letters/digits/hyphens, no leading/trailing hyphen). A token fitting none of these throws IllegalArgumentException('Invalid hostname provided').","triggerScenarios":"Host tokens containing underscores (web_01.example.com), IPv6 addresses (colons match nothing), malformed IPs like 192.168.0.256, stray punctuation, or trailing dots — none satisfies the CIDR patterns or HOSTNAME_FORMAT.","commonSituations":"Corporate machine names with underscores (legal on Windows networks, illegal as RFC-1121/1123 hostnames); IPv6-only clients; typos introduced while editing nfs.exports.","solutions":["Replace underscores with hyphens in the exports entry, or use a wildcard regex form (any token containing * or ? is treated as a regex)","Use IPv4/CIDR or RFC-1123 hostname forms only; this parser has no IPv6 branch","Validate each entry (hostname regex or InetAddress parse) before adding it to nfs.exports"],"exampleFix":"# before\nweb_01.example.com rw\n\n# after\nweb-01.example.com rw","handlingStrategy":"validation","validationCode":"private static final Pattern LABEL =\n    Pattern.compile(\"[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\");\n\nboolean ok = host.equals(\"*\")\n    || host.matches(\"\\\\d+\\\\.\\\\d+\\\\.\\\\d+\\\\.\\\\d+/\\\\d+\") // CIDR\n    || (\"*?[]()\".chars().anyMatch(c -> host.indexOf(c) >= 0)) // regex forms\n    || LABEL.matcher(host).matches() && host.equals(host); // hostname labels joined by dots\nif (!ok) throw new IllegalArgumentException(\"Unsupported host entry: \" + host);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid underscores in host entries — use hyphens or a wildcard regex form","This parser has no IPv6 support: map IPv6 clients by other means","Run a config lint over nfs.exports entries matching the classifier rules (anonymous, CIDR, regex, RFC-1123 hostname)"],"tags":["nfs","hostname","exports","validation"],"backgroundTag":"invalid-hostname","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}