sgl-project/sglang · error · ValueError
Hugging Face weight URL has no filename: {source!r}
Error message
Hugging Face weight URL has no filename: {source!r} What it means
Raised when a Hugging Face URL passed to parse_weight_source resolves to a repo root with no filename component (e.g. https://huggingface.co/owner/repo with no /resolve/.../file path). The parser requires a concrete file path so it can pin an exact weight file. Without a tail the library cannot construct an unambiguous WeightSource.
Source
Thrown at python/sglang/multimodal_gen/runtime/weights/source.py:108
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",
repo_id=repo_id,
revision=selected_revision,
filename=_validate_relative_hub_path(tail, "filename"),
)
def parse_weight_source(
source: str,
*,
revision: str | None = None,
) -> WeightSource:
"""Parse local paths, Hub repo IDs, subfolders, and exact Hub URLs."""
expanded = os.path.expanduser(source)
parsed = urlparse(source)
if parsed.scheme in ("http", "https"):View on GitHub (pinned to 0132848349)
Solutions
- Append the file path to the URL, e.g. https://huggingface.co/owner/repo/resolve/main/model.safetensors
- If you mean the whole repo or a subfolder, pass the plain 'owner/repo' or 'owner/repo/subfolder' reference instead of a URL
Example fix
# before
parse_weight_source("https://huggingface.co/org/repo")
# after
parse_weight_source("https://huggingface.co/org/repo/resolve/main/model.safetensors") Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlparse
def hf_url_has_filename(url: str) -> bool:
parts = [p for p in urlparse(url).path.split("/") if p]
# expect owner/repo/(resolve|blob)/rev/file...
return len(parts) >= 5 Prevention
- Always copy the full file URL from the HF Files page including /resolve/<rev>/
- Pre-validate URL structure before calling parse_weight_source
When it happens
Trigger: Calling parse_weight_source (or resolve_weight) with a HF URL whose path ends at the repo or subfolder level, omitting the /revision/resolve/<rev>/<path> or /blob/<rev>/<path> suffix.
Common situations: Copy-pasting a repo page URL instead of a file URL from the HF website; constructing URLs programmatically and forgetting the filename segment.
Related errors
- Invalid Hugging Face {field_name}: {path!r}
- Only huggingface.co weight URLs are supported; use a local p
- Weight URL pins revision {url_revision!r}, which conflicts w
- 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/051416b46f0d3b20.
Report an issue: GitHub.