sgl-project/sglang · error · ValueError
{field_name} is required
Error message
{field_name} is required What it means
Thrown by parse_tcp_host_port when the provided endpoint value is None or whitespace-only. The field named by field_name is mandatory for building a valid tcp://host:port endpoint.
Source
Thrown at python/sglang/multimodal_gen/runtime/utils/common.py:125
if len(set(parsed)) != len(parsed):
raise ValueError(f"--gpu-ids contains duplicate GPU ids: {parsed}")
return parsed
def parse_size(size: str) -> tuple[int | None, int | None]:
try:
parts = size.lower().replace(" ", "").split("x")
if len(parts) != 2:
raise ValueError
return int(parts[0]), int(parts[1])
except ValueError:
return None, None
def parse_tcp_host_port(value: str | None, field_name: str) -> tuple[str, int]:
if value is None or not str(value).strip():
raise ValueError(f"{field_name} is required")
addr = str(value).strip()
if addr.startswith("tcp://"):
addr = addr[len("tcp://") :]
try:
host, port_str = addr.rsplit(":", 1)
except ValueError as exc:
raise ValueError(
f"{field_name} must be formatted as tcp://host:port or host:port"
) from exc
host = host.strip()
port_str = port_str.strip()
if not host or not port_str:
raise ValueError(f"{field_name} must include both host and port: {value!r}")
try:View on GitHub (pinned to 0132848349)
Solutions
- Set the required endpoint field (host:port or tcp://host:port) in the config object before deriving endpoints
- Check the env var / CLI flag that feeds this field is actually set and non-empty
- Print/dump the config right before the call to confirm which field_name is missing
Example fix
# before pool.result_endpoint = None # after pool.result_endpoint = "127.0.0.1:5555"
Defensive patterns
Strategy: validation
Validate before calling
if not endpoint or not str(endpoint).strip():
raise SystemExit("result endpoint is required (host:port)") Type guard
def is_set_endpoint(v) -> bool:
return v is not None and bool(str(v).strip()) Try / catch
try:
host, port = parse_tcp_host_port(cfg.endpoint, "endpoint")
except ValueError as e:
if "is required" in str(e):
cfg.endpoint = pick_free_port_endpoint()
else:
raise Prevention
- Fail fast at config load on missing endpoint fields
- Log the resolved config before deriving endpoints
When it happens
Trigger: Calling parse_tcp_host_port(None, ...) or parse_tcp_host_port(" ", ...) — e.g. derive_pool_result_endpoint receiving an unset result endpoint field from the pool config.
Common situations: Missing required config field (endpoint not set in YAML/CLI), environment variable for the ZMQ endpoint unset, or default config changed between versions making a previously-optional field required.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- {field_name} must be formatted as tcp://host:port or host:po
- {field_name} must include both host and port: {value!r}
- {field_name} port must be an integer: {port_str}
- {field_name} port must be between 0 and 65535: {port}
- Invalid endpoint: must contain 'inproc' or 'tcp'
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/50557c75f13bbfb9.
Report an issue: GitHub.