sgl-project/sglang · error · ValueError
allowed media domains cannot be empty
Error message
allowed media domains cannot be empty
What it means
After stripping whitespace and trailing dots, an allowed-media-domains entry became an empty string. The normalizer strips leading/trailing whitespace and a single trailing dot (DNS root form), so inputs like ' ' or '.' normalize to nothing and are rejected because an empty allowlist entry would match nothing and usually indicates a config typo.
Source
Thrown at python/sglang/srt/utils/common.py:1526
torch.xpu.manual_seed_all(seed)
_mm_http_session = threading.local()
_DEFAULT_MEDIA_URL_MAX_FILE_SIZE_MB = 64
_MAX_MEDIA_URL_REDIRECTS = 5
_MEDIA_URL_REDIRECT_STATUS_CODES = {301, 302, 303, 307, 308}
_allowed_media_domains: frozenset[str] = frozenset()
_media_url_max_file_size_bytes = _DEFAULT_MEDIA_URL_MAX_FILE_SIZE_MB * 1024 * 1024
def _normalize_media_domain(domain: str) -> str:
if not isinstance(domain, str):
raise ValueError("allowed media domains must be strings")
domain = domain.strip().rstrip(".")
if not domain:
raise ValueError("allowed media domains cannot be empty")
if "://" in domain or any(char in domain for char in "/?#@"):
raise ValueError(
f"Invalid allowed media domain {domain!r}: provide a hostname only"
)
# Brackets are URL syntax, not part of an IPv6 hostname.
if domain.startswith("[") and domain.endswith("]"):
domain = domain[1:-1]
try:
return str(ipaddress.ip_address(domain))
except ValueError:
if ":" in domain:
raise ValueError(
f"Invalid allowed media domain {domain!r}: ports are not supported"
)
try:
normalized = domain.encode("idna").decode("ascii").lower()View on GitHub (pinned to 0132848349)
Solutions
- Strip and filter empty entries when parsing user input: [d for d in raw.split(',') if d.strip()]
- Fix the typo in the config file / CLI flag
- Validate the allowlist before server start
Example fix
# before configure_media_url_security(allowed_media_domains=['example.com', '', '']) # after configure_media_url_security(allowed_media_domains=[d for d in ['example.com', '', ''] if d.strip()])
Defensive patterns
Strategy: validation
Validate before calling
domains = [d.strip().rstrip('.') for d in raw.split(',')]
domains = [d for d in domains if d] # drop empties before configure() Prevention
- Filter empty strings when splitting user input
- Lint config values at startup
When it happens
Trigger: configure_media_url_security(allowed_media_domains=['', ' .', '.']) — entry reduces to empty after domain.strip().rstrip('.').
Common situations: Comma-splitting a user-supplied --allowed-media-domains value with trailing commas ('a.com,,b.com'); copy-paste config with stray dots; empty strings from YAML list entries.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- media_url_max_file_size_mb must be non-negative
- allowed media domains must be strings
- Invalid allowed media domain {domain!r}: provide a hostname
- Invalid allowed media domain {domain!r}: ports are not suppo
- Invalid allowed media domain {domain!r}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/0393a0d0e3d44746.
Report an issue: GitHub.