{"record":{"id":"6efaa563f1ea844e","repo":"openzipkin/zipkin","slug":"s-has-an-empty-host","errorCode":null,"errorMessage":"%s has an empty host","messagePattern":"(.+?) has an empty host","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/internal/HostAndPort.java","lineNumber":74,"sourceCode":"    int endHostIndex = hostPort.length();\n    if (hostPort.startsWith(\"[\")) { // Bracketed IPv6\n      endHostIndex = hostPort.lastIndexOf(']') + 1;\n      host = hostPort.substring(1, endHostIndex == 0 ? 1 : endHostIndex - 1);\n      if (!Endpoint.newBuilder().parseIp(host)) { // reuse our IPv6 validator\n        throw new IllegalArgumentException(hostPort + \" contains an invalid IPv6 literal\");\n      }\n    } else {\n      int colonIndex = hostPort.indexOf(':'), nextColonIndex = hostPort.lastIndexOf(':');\n      if (colonIndex >= 0) {\n        if (colonIndex == nextColonIndex) { // only 1 colon\n          host = hostPort.substring(0, colonIndex);\n          endHostIndex = colonIndex;\n        } else if (!Endpoint.newBuilder().parseIp(hostPort)) { // reuse our IPv6 validator\n          throw new IllegalArgumentException(hostPort + \" is an invalid IPv6 literal\");\n        }\n      }\n    }\n    if (host.isEmpty()) throw new IllegalArgumentException(hostPort + \" has an empty host\");\n    if (endHostIndex + 1 < hostPort.length() && hostPort.charAt(endHostIndex) == ':') {\n      return new HostAndPort(host, validatePort(hostPort.substring(endHostIndex + 1), hostPort));\n    }\n    return new HostAndPort(host, defaultPort);\n  }\n\n  static int validatePort(String portString, String hostPort) {\n    for (int i = 0, length = portString.length(); i < length; i++) {\n      char c = portString.charAt(i);\n      if (c >= '0' && c <= '9') continue; // isDigit\n      throw new IllegalArgumentException(hostPort + \" has an invalid port\");\n    }\n    int result = Integer.parseInt(portString);\n    if (result == 0 || result > 0xffff) {\n      throw new IllegalArgumentException(hostPort + \" has an invalid port\");\n    }\n    return result;\n  }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/internal/HostAndPort.java#L56-L92","documentation":"Thrown by HostAndPort.fromString when, after stripping the port and any brackets, the host portion is empty — e.g. ':9042', '[]:9042', or an empty string. A contact point must name a host.","triggerScenarios":"Strings like ':9042' (port only), '[]:9042' (empty brackets), or '' after trimming.","commonSituations":"Templated configs where the host placeholder is empty (KUBE_SERVICE_NAME unset); string splitting that leaves an empty element.","solutions":["Include the host: 'cassandra:9042'.","Default empty host config values (e.g. to 'localhost') or fail config validation with a clearer message.","Skip blank entries when parsing comma-separated contact-point lists."],"exampleFix":"# before\nCASSANDRA_CONTACT_POINTS=:9042\n\n# after\nCASSANDRA_CONTACT_POINTS=cassandra:9042","handlingStrategy":"validation","validationCode":"if (hostPort == null || hostPort.isBlank() || hostPort.startsWith(\":\") || hostPort.startsWith(\"[]\")) throw new IllegalArgumentException(\"Contact point needs a host: \" + hostPort);","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) { if (e.getMessage().endsWith(\"has an empty host\")) failConfigValidation(e.getMessage()); else throw e; }","preventionTips":["Fail fast on empty templated host values at config load.","Skip blank elements when splitting contact-point lists."],"tags":["cassandra","zipkin","contact-points","validation","configuration"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}