{"record":{"id":"f2e3c4a6057e302c","repo":"stanfordnlp/CoreNLP","slug":"invalid-subnet-subnet","errorCode":null,"errorMessage":"Invalid subnet: ${subnet}","messagePattern":"Invalid subnet: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java","lineNumber":653,"sourceCode":"\n\n  /**\n   * Adapted from: https://stackoverflow.com/questions/4209760/validate-an-ip-address-with-mask\n   */\n  private static Pair<Inet4Address, Integer> parseSubnet(String subnet) {\n    String[] parts = subnet.split(\"/\");\n    String ip = parts[0];\n    int prefix;\n\n    if (parts.length < 2) {\n      prefix = 0;\n    } else {\n      prefix = Integer.parseInt(parts[1]);\n    }\n    try {\n      return Pair.makePair((Inet4Address) InetAddress.getByName(ip), prefix);\n    } catch (UnknownHostException e) {\n      throw new IllegalArgumentException(\"Invalid subnet: \" + subnet);\n    }\n  }\n\n\n  /**\n   * Adapted from: https://stackoverflow.com/questions/4209760/validate-an-ip-address-with-mask\n   */\n  @SuppressWarnings(\"PointlessBitwiseExpression\")\n  private static boolean netMatch(Pair<Inet4Address, Integer> subnet, Inet4Address addr ){\n    byte[] b = subnet.first.getAddress();\n    int ipInt = ((b[0] & 0xFF) << 24) |\n        ((b[1] & 0xFF) << 16) |\n        ((b[2] & 0xFF) << 8)  |\n        ((b[3] & 0xFF) << 0);\n    byte[] b1 = addr.getAddress();\n    int ipInt1 = ((b1[0] & 0xFF) << 24) |\n        ((b1[1] & 0xFF) << 16) |\n        ((b1[2] & 0xFF) << 8)  |","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java#L635-L671","documentation":"parseSubnet() parses whitelist entries of the form 'ip/prefix'. If InetAddress.getByName cannot resolve the IP portion (malformed IPv4 address), the UnknownHostException is rethrown as IllegalArgumentException naming the bad subnet string.","triggerScenarios":"Starting the server with -whitelist (or annotator/subnet config) containing a malformed IPv4 subnet such as '999.1.1.0/24', '10.0.0/8', or a hostname that does not resolve, with a /prefix part.","commonSituations":"Typos in subnet CIDR notation; using IPv6 in a slot expecting Inet4Address; copy-pasting masks like 255.255.255.0 instead of prefix length; Docker/hostnames in the whitelist that fail DNS resolution.","solutions":["Fix the whitelist entry to valid CIDR form, e.g. 10.0.0.0/8 or 127.0.0.1/32","Verify the IP portion resolves with `nslookup` or `ping` before adding hostnames","Use prefix lengths (0-32) rather than dotted netmasks","Check number of / parts: exactly ip/prefix, no extra slashes"],"exampleFix":"// before\n-whitelist \"192.168.1.0/255.255.255.0\"\n// after\n-whitelist \"192.168.1.0/24\"","handlingStrategy":"validation","validationCode":"for (String subnet : whitelist.split(\",\")) {\n  String[] p = subnet.split(\"/\");\n  if (p.length != 2) throw new IllegalArgumentException(\"Need ip/prefix: \" + subnet);\n  if (!p[0].matches(\"(\\\\d{1,3}\\\\.){3}\\\\d{1,3}\")) throw new IllegalArgumentException(\"Bad IPv4: \" + subnet);\n  int prefix = Integer.parseInt(p[1]);\n  if (prefix < 0 || prefix > 32) throw new IllegalArgumentException(\"Bad prefix: \" + subnet);\n}","typeGuard":null,"tryCatchPattern":"try {\n  startServerWithWhitelist(whitelist);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Invalid subnet\")) {\n    log.error(\"Fix whitelist entry: \" + e.getMessage());\n    throw e; // config error, do not auto-retry\n  } else throw e;\n}","preventionTips":["Validate CIDR entries with a regex or library before launching","Use prefix lengths, never dotted netmasks","Resolve hostnames to IPs before putting them in the whitelist"],"tags":["network","configuration","cidr","whitelist"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}