sgl-project/sglang · error · ValueError
Empty address string
Error message
Empty address string
What it means
NetworkAddress.parse requires a non-empty address string; an empty/whitespace input (or None coerced to '') raises ValueError('Empty address string') before any parsing branch runs.
Source
Thrown at python/sglang/srt/utils/network.py:526
@staticmethod
def parse(addr: str) -> NetworkAddress:
"""Parse a ``host:port`` string into a ``NetworkAddress``.
Accepted formats::
[::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:View on GitHub (pinned to 0132848349)
Solutions
- Default the value before parsing: addr_str or "127.0.0.1:0".
- Fail fast on missing config at startup with a clear message.
- Trim/validate config strings before reaching parse.
Example fix
# before
NetworkAddress.parse(os.environ.get("DIST_ADDR", ""))
# after
NetworkAddress.parse(os.environ.get("DIST_ADDR") or "127.0.0.1:8000") Defensive patterns
Strategy: validation
Validate before calling
addr = (os.environ.get("DIST_ADDR") or "").strip()
if not addr:
raise SystemExit("DIST_ADDR is required") Type guard
def is_nonempty_addr(s) -> bool:
return isinstance(s, str) and bool(s.strip()) Prevention
- Default optional address env vars at one place in startup code.
When it happens
Trigger: parse("") or parse(os.environ.get("SGLANG_ADDR", "")) where the env var is unset/empty.
Common situations: Optional env vars not set and defaults wired as empty strings; templated config producing blank endpoints.
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 global_segment_size: missing number before 'gb'
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/867b5336a42d3258.
Report an issue: GitHub.