{"record":{"id":"78bffbdf2208bc2a","repo":"sgl-project/sglang","slug":"field-name-must-include-both-host-and-port-val","errorCode":null,"errorMessage":"{field_name} must include both host and port: {value!r}","messagePattern":"(.+?) must include both host and port: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/common.py","lineNumber":141,"sourceCode":"def parse_tcp_host_port(value: str | None, field_name: str) -> tuple[str, int]:\n    if value is None or not str(value).strip():\n        raise ValueError(f\"{field_name} is required\")\n\n    addr = str(value).strip()\n    if addr.startswith(\"tcp://\"):\n        addr = addr[len(\"tcp://\") :]\n\n    try:\n        host, port_str = addr.rsplit(\":\", 1)\n    except ValueError as exc:\n        raise ValueError(\n            f\"{field_name} must be formatted as tcp://host:port or host:port\"\n        ) from exc\n\n    host = host.strip()\n    port_str = port_str.strip()\n    if not host or not port_str:\n        raise ValueError(f\"{field_name} must include both host and port: {value!r}\")\n\n    try:\n        port = int(port_str)\n    except ValueError as exc:\n        raise ValueError(f\"{field_name} port must be an integer: {port_str}\") from exc\n\n    if port < 0 or port > 65535:\n        raise ValueError(f\"{field_name} port must be between 0 and 65535: {port}\")\n    return host, port\n\n\ndef format_tcp_endpoint(host: str, port: int, field_name: str) -> str:\n    if port < 0 or port > 65535:\n        raise ValueError(f\"{field_name} port must be between 0 and 65535: {port}\")\n    return f\"tcp://{host}:{port}\"\n\n\ndef configure_ipv6(dist_init_addr):","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/common.py#L123-L159","documentation":"Thrown by parse_tcp_host_port when the string splits on ':' but either the host or the port side is empty after stripping (e.g. \":5555\" or \"host:\"). Both parts are required.","triggerScenarios":"Passing \":9000\" (no host), \"127.0.0.1:\" (no port), or \" : \" to parse_tcp_host_port.","commonSituations":"Default placeholder like \"{host}:{port}\" with one variable unfilled; trailing colon from string concatenation where the port variable was empty.","solutions":["Fill in both host and port in the endpoint string","Check template/format-string interpolation that builds the endpoint for empty variables"],"exampleFix":"# before\nendpoint = f\"{host}:\"  # port unset\n# after\nendpoint = f\"{host}:{port}\"","handlingStrategy":"validation","validationCode":"v = endpoint.removeprefix(\"tcp://\")\nhost, _, port = v.rpartition(\":\")\nassert host.strip() and port.strip(), \"both host and port required\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check interpolated template variables for emptiness before building endpoint strings"],"tags":["zmq","endpoint","validation"],"backgroundTag":"invalid-endpoint-format","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}