{"record":{"id":"f7738028d8f81bb4","repo":"sgl-project/sglang","slug":"invalid-ipv6-address-host","errorCode":null,"errorMessage":"invalid IPv6 address: {host}","messagePattern":"invalid IPv6 address: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/common.py","lineNumber":170,"sourceCode":"\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\n    host = addr[: end + 1]\n\n    # this only validates the address without brackets: we still need the below checks.\n    # if it's invalid, immediately raise an error so we know it's not formatting issues.\n    if not is_valid_ipv6_address(host[1:end]):\n        raise ValueError(f\"invalid IPv6 address: {host}\")\n\n    port_str = None\n    if len(addr) > end + 1:\n        if addr[end + 1] == \":\":\n            port_str = addr[end + 2 :]\n        else:\n            raise ValueError(\"received IPv6 address format: expected ':' after ']'\")\n\n    if not port_str:\n        raise ValueError(\n            \"a port must be specified in IPv6 address (format: [ipv6]:port)\"\n        )\n\n    try:\n        port = int(port_str)\n    except ValueError:\n        raise ValueError(f\"invalid port in IPv6 address: '{port_str}'\")\n    return port, host","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/common.py#L152-L188","documentation":"Thrown by configure_ipv6 when the bracketed host fails the is_valid_ipv6_address check, i.e. the text between '[' and ']' is not a syntactically valid IPv6 address.","triggerScenarios":"Passing \"[not-an-addr]:29500\", \"[192.168.1.1]:29500\" (IPv4 in brackets), or a truncated IPv6 like \"[fe80::]:29500\" variant that fails validation.","commonSituations":"Copy-paste truncating the address; interface/zone suffixes or a hostname accidentally placed inside brackets.","solutions":["Use a full valid IPv6 literal, e.g. \"[2001:db8::1]:29500\"","Remove IPv4 addresses or hostnames from bracketed form","Validate the address with ipaddress.IPv6Address before launching"],"exampleFix":"# before\naddr = \"[192.168.1.5]:29500\"\n# after\naddr = \"192.168.1.5:29500\"  # or a real IPv6 like [2001:db8::1]:29500","handlingStrategy":"validation","validationCode":"import ipaddress\ntry:\n    ipaddress.IPv6Address(addr.strip(\"[]\").rsplit(\":\", 1)[0] if \"]\" in addr else None)\n    ok = True\nexcept Exception:\n    ok = False","typeGuard":"def valid_ipv6_with_port(addr: str) -> bool:\n    try:\n        host = addr[1:addr.index(\"]\")]\n        ipaddress.IPv6Address(host)\n        return addr[addr.index(\"]\") + 1] == \":\" and addr[addr.index(\"]\") + 2:].isdigit()\n    except (ValueError, IndexError):\n        return False","tryCatchPattern":null,"preventionTips":["Validate with ipaddress.IPv6Address before passing user-provided addresses"],"tags":["ipv6","distributed","network","validation"],"backgroundTag":"invalid-ipv6-address","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}