sgl-project/sglang · error · ValueError
Hugging Face weight URL has no model repo: {source!r}
Error message
Hugging Face weight URL has no model repo: {source!r} What it means
Raised by _parse_huggingface_url when a huggingface.co URL has fewer than two non-empty path segments, so no owner/repo model id can be extracted (e.g. https://huggingface.co/ or .../org only).
Source
Thrown at python/sglang/multimodal_gen/runtime/weights/source.py:80
f"Weight URL pins revision {url_revision!r}, which conflicts with "
f"revision {revision!r}"
)
return url_revision or revision
def _parse_huggingface_url(source: str, revision: str | None) -> WeightSource:
parsed = urlparse(source)
if parsed.netloc.lower() not in ("huggingface.co", "www.huggingface.co"):
raise ValueError(
"Only huggingface.co weight URLs are supported; use a local path "
"or an owner/repo reference for other sources"
)
raw_parts = [part for part in parsed.path.split("/") if part]
if raw_parts and raw_parts[0] in ("datasets", "spaces"):
raise ValueError("Diffusion weights must come from a Hugging Face model repo")
if len(raw_parts) < 2:
raise ValueError(f"Hugging Face weight URL has no model repo: {source!r}")
repo_id = "/".join(unquote(part) for part in raw_parts[:2])
validate_repo_id(repo_id)
action = raw_parts[2] if len(raw_parts) > 2 else None
if action is None:
return WeightSource(
original=source,
kind="huggingface",
repo_id=repo_id,
revision=revision,
)
if action not in ("tree", "blob", "resolve") or len(raw_parts) < 4:
raise ValueError(f"Unsupported Hugging Face weight URL: {source!r}")
url_revision = unquote(raw_parts[3])
selected_revision = _merge_revision(url_revision, revision)
tail = "/".join(unquote(part) for part in raw_parts[4:])
if action == "tree":View on GitHub (pinned to 0132848349)
Solutions
- Use a complete URL with both owner and repo: https://huggingface.co/owner/repo
- Or use the shorthand 'owner/repo' form
- Validate the URL has at least two path segments before passing it
Example fix
# before
parse_weight_source("https://huggingface.co/stability")
# after
parse_weight_source("https://huggingface.co/stabilityai/stable-diffusion-xl") Defensive patterns
Strategy: validation
Validate before calling
parts = [p for p in urlparse(url).path.split("/") if p]
if urlparse(url).netloc and len(parts) < 2:
raise ValueError(f"URL lacks owner/repo: {url}") Type guard
def url_has_repo_id(url: str) -> bool:
if "://" not in url:
return "/" in url.strip("/") # owner/repo form
return len([p for p in urlparse(url).path.split("/") if p]) >= 2 Prevention
- Validate URLs contain owner/repo before startup
- Prefer the 'owner/repo' shorthand in configs
When it happens
Trigger: Calling parse_weight_source with 'https://huggingface.co' or 'https://huggingface.co/org'.
Common situations: Truncated copy-pasted URLs, typos dropping the repo name, or string interpolation that leaves the repo segment empty.
Related errors
- Invalid Hugging Face {field_name}: {path!r}
- Weight URL pins revision {url_revision!r}, which conflicts w
- Only huggingface.co weight URLs are supported; use a local p
- Diffusion weights must come from a Hugging Face model repo
- Unsupported Hugging Face weight URL: {source!r}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/c60b41558dd93361.
Report an issue: GitHub.