sgl-project/sglang · error · ValueError
Unsupported Hugging Face weight URL: {source!r}
Error message
Unsupported Hugging Face weight URL: {source!r} What it means
Raised by _parse_huggingface_url when the third path segment (the 'action') is not one of tree/blob/resolve, or when there are fewer than 4 path segments after a valid action. Only repo-root, /tree/<rev>[/subfolder], and /blob|resolve/<rev>/<file> URL shapes are supported.
Source
Thrown at python/sglang/multimodal_gen/runtime/weights/source.py:93
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":
subfolder = _validate_relative_hub_path(tail, "subfolder") if tail else None
return WeightSource(
original=source,
kind="huggingface",
repo_id=repo_id,
revision=selected_revision,
subfolder=subfolder,
)
if not tail:
raise ValueError(f"Hugging Face weight URL has no filename: {source!r}")
return WeightSource(
original=source,
kind="huggingface",View on GitHub (pinned to 0132848349)
Solutions
- Use the canonical forms: repo root, /tree/<revision>/<subfolder>, or /resolve|blob/<revision>/<filename>
- Copy the URL from the Hub's Files or file-view page rather than the history tab
- If you only need the repo, strip everything after org/repo
Example fix
# before
parse_weight_source("https://huggingface.co/org/repo/commits/main")
# after
parse_weight_source("https://huggingface.co/org/repo/tree/main") Defensive patterns
Strategy: type-guard
Validate before calling
parts = [p for p in urlparse(url).path.split("/") if p]
action = parts[2] if len(parts) > 2 else None
if action is not None and (action not in ("tree", "blob", "resolve") or len(parts) < 4):
url = f"https://huggingface.co/{parts[0]}/{parts[1]}" # reduce to repo root Type guard
def is_supported_hf_url_shape(url: str) -> bool:
parts = [p for p in urlparse(url).path.split("/") if p]
if len(parts) <= 2:
return True
return parts[2] in ("tree", "blob", "resolve") and len(parts) >= 4 Prevention
- Copy URLs from the Hub file browser (Files and versions tab)
- Normalize any weight URL down to owner/repo plus explicit subfolder/revision args
When it happens
Trigger: Calling parse_weight_source with URLs like https://huggingface.co/org/repo/commits/main, .../org/repo/tree (missing revision), or other Hub pages (discussions, settings).
Common situations: Copying a commits/history page URL from the Hub, or truncating a tree/blob URL so the revision segment is missing.
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
- Hugging Face weight URL has no model repo: {source!r}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/12c80a157505eff2.
Report an issue: GitHub.