sgl-project/sglang · error · ValueError
Missing closing bracket in IPv6 address: {addr!r}
Error message
Missing closing bracket in IPv6 address: {addr!r} What it means
In NetworkAddress.parse, a leading '[' enters the bracketed-IPv6 branch; if no matching ']' is found the string is malformed (e.g., '[::1' or '[::1]8080' missing the port separator handled later) and ValueError is raised naming the address.
Source
Thrown at python/sglang/srt/utils/network.py:532
[::1]:8000 → NetworkAddress("::1", 8000)
127.0.0.1:8000 → NetworkAddress("127.0.0.1", 8000)
my-hostname:8000 → NetworkAddress("my-hostname", 8000)
IPv6 addresses **must** be bracketed. Bare ``::1:8000`` is
ambiguous and will raise ``ValueError``.
Raises:
ValueError: If the string cannot be unambiguously parsed.
"""
if not addr:
raise ValueError("Empty address string")
# --- Bracketed IPv6: [addr]:port ---
if addr.startswith("["):
close = addr.find("]")
if close == -1:
raise ValueError(f"Missing closing bracket in IPv6 address: {addr!r}")
host = addr[1:close]
if not _is_ipv6(host):
raise ValueError(f"Invalid IPv6 address inside brackets: {host!r}")
rest = addr[close + 1 :]
if not rest.startswith(":") or len(rest) < 2:
raise ValueError(
f"Expected ':port' after closing bracket, got: {rest!r}"
)
return NetworkAddress(host, _parse_port(rest[1:]))
# --- Plain host:port (IPv4 / hostname) ---
if ":" not in addr:
raise ValueError(f"Missing port in address (expected host:port): {addr!r}")
host, port_str = addr.rsplit(":", 1)
if not host:
raise ValueError(f"Empty host in address: {addr!r}")
# Guard against bare IPv6 slipping through
if ":" in host and _is_ipv6(host):View on GitHub (pinned to 0132848349)
Solutions
- Use the canonical form [ipv6]:port, e.g. "[::1]:8000".
- Quote the address in shell/YAML to prevent bracket stripping.
- Construct via NetworkAddress(host, port) directly when building programmatically.
Example fix
# before
NetworkAddress.parse("fe80::1:8000") # ambiguous / unbracketed
# after
NetworkAddress.parse("[fe80::1]:8000") Defensive patterns
Strategy: validation
Validate before calling
def valid_endpoint(s: str) -> bool:
return s.count("[") == s.count("]") and (not s.startswith("[") or s.find("]") != -1) Prevention
- Always quote IPv6 endpoints ([::1]:port) in shells and YAML.
- Build addresses with NetworkAddress(host, port) instead of string concatenation.
When it happens
Trigger: parse("[fe80::1") — an IPv6 endpoint where the closing bracket was lost in quoting/shell interpolation.
Common situations: Shell commands dropping brackets, YAML configs mangling [..] syntax, or hand-built address strings concatenating host and port without the ']:' separator.
Related errors
- invalid IPv6 address format: missing ']'
- invalid IPv6 address: {host}
- received IPv6 address format: expected ':' after ']'
- a port must be specified in IPv6 address (format: [ipv6]:por
- Invalid port number: {s!r}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4ca36d7e9d8ff535.
Report an issue: GitHub.