{"record":{"id":"95d6568d7dc582b1","repo":"sgl-project/sglang","slug":"field-name-must-be-formatted-as-tcp-host-port","errorCode":null,"errorMessage":"{field_name} must be formatted as tcp://host:port or host:port","messagePattern":"(.+?) must be formatted as tcp://host:port or host:port","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/common.py","lineNumber":134,"sourceCode":"        if len(parts) != 2:\n            raise ValueError\n        return int(parts[0]), int(parts[1])\n    except ValueError:\n        return None, None\n\n\ndef 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","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/common.py#L116-L152","documentation":"Thrown by parse_tcp_host_port when addr.rsplit(\":\", 1) raises ValueError, i.e. the string contains no ':' at all so it cannot be split into host and port. This is a defensive branch (rsplit on a plain string rarely raises) covering malformed input lacking a colon.","triggerScenarios":"Passing a colon-less string like \"localhost\" or \"myhost\" to parse_tcp_host_port after the tcp:// prefix is stripped.","commonSituations":"User supplies only a hostname or only a port in an endpoint config; a template renders an incomplete endpoint string.","solutions":["Include the port: use host:port or tcp://host:port format","If you meant to use a default port, append it explicitly to the configured value"],"exampleFix":"# before\nendpoint = \"localhost\"\n# after\nendpoint = \"localhost:5555\"","handlingStrategy":"validation","validationCode":"assert \":\" in endpoint, f\"endpoint {endpoint!r} must be host:port\"","typeGuard":"def looks_like_host_port(v: str) -> bool:\n    v = v.removeprefix(\"tcp://\")\n    return \":\" in v","tryCatchPattern":null,"preventionTips":["Always format endpoints with f\"{host}:{port}\" rather than hand-typing"],"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"}