{"record":{"id":"3c79ecec7c83fa07","repo":"sgl-project/sglang","slug":"field-name-port-must-be-an-integer-port-str","errorCode":null,"errorMessage":"{field_name} port must be an integer: {port_str}","messagePattern":"(.+?) port must be an integer: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/common.py","lineNumber":146,"sourceCode":"    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):\n    addr = dist_init_addr\n    end = addr.find(\"]\")\n    if end == -1:\n        raise ValueError(\"invalid IPv6 address format: missing ']'\")\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/common.py#L128-L164","documentation":"Thrown by parse_tcp_host_port when int(port_str) fails, i.e. the text after the last ':' is not a valid integer (e.g. \"host:abc\" or \"host:55 55\").","triggerScenarios":"Passing \"localhost:http\" or \"1.2.3.4:5555a\" to parse_tcp_host_port.","commonSituations":"Using a service name instead of a numeric port; a stray character or space appended to the port; copy-paste including a footnote marker.","solutions":["Replace service names with the numeric port (e.g. 80, 5555)","Strip any non-digit characters from the port substring","Verify the port field in the config is typed as an integer before string formatting"],"exampleFix":"# before\nendpoint = \"localhost:http\"\n# after\nendpoint = \"localhost:80\"","handlingStrategy":"validation","validationCode":"port_str = endpoint.rsplit(\":\", 1)[1]\nassert port_str.isdigit(), f\"port {port_str!r} not an integer\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use numeric ports, never service names, in ZMQ endpoint configs"],"tags":["zmq","endpoint","port","validation"],"backgroundTag":"invalid-endpoint-format","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}