{"record":{"id":"c60b41558dd93361","repo":"sgl-project/sglang","slug":"hugging-face-weight-url-has-no-model-repo-source","errorCode":null,"errorMessage":"Hugging Face weight URL has no model repo: {source!r}","messagePattern":"Hugging Face weight URL has no model repo: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/weights/source.py","lineNumber":80,"sourceCode":"            f\"Weight URL pins revision {url_revision!r}, which conflicts with \"\n            f\"revision {revision!r}\"\n        )\n    return url_revision or revision\n\n\ndef _parse_huggingface_url(source: str, revision: str | None) -> WeightSource:\n    parsed = urlparse(source)\n    if parsed.netloc.lower() not in (\"huggingface.co\", \"www.huggingface.co\"):\n        raise ValueError(\n            \"Only huggingface.co weight URLs are supported; use a local path \"\n            \"or an owner/repo reference for other sources\"\n        )\n\n    raw_parts = [part for part in parsed.path.split(\"/\") if part]\n    if raw_parts and raw_parts[0] in (\"datasets\", \"spaces\"):\n        raise ValueError(\"Diffusion weights must come from a Hugging Face model repo\")\n    if len(raw_parts) < 2:\n        raise ValueError(f\"Hugging Face weight URL has no model repo: {source!r}\")\n\n    repo_id = \"/\".join(unquote(part) for part in raw_parts[:2])\n    validate_repo_id(repo_id)\n    action = raw_parts[2] if len(raw_parts) > 2 else None\n    if action is None:\n        return WeightSource(\n            original=source,\n            kind=\"huggingface\",\n            repo_id=repo_id,\n            revision=revision,\n        )\n    if action not in (\"tree\", \"blob\", \"resolve\") or len(raw_parts) < 4:\n        raise ValueError(f\"Unsupported Hugging Face weight URL: {source!r}\")\n\n    url_revision = unquote(raw_parts[3])\n    selected_revision = _merge_revision(url_revision, revision)\n    tail = \"/\".join(unquote(part) for part in raw_parts[4:])\n    if action == \"tree\":","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/weights/source.py#L62-L98","documentation":"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).","triggerScenarios":"Calling parse_weight_source with 'https://huggingface.co' or 'https://huggingface.co/org'.","commonSituations":"Truncated copy-pasted URLs, typos dropping the repo name, or string interpolation that leaves the repo segment empty.","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"],"exampleFix":"# before\nparse_weight_source(\"https://huggingface.co/stability\")\n# after\nparse_weight_source(\"https://huggingface.co/stabilityai/stable-diffusion-xl\")","handlingStrategy":"validation","validationCode":"parts = [p for p in urlparse(url).path.split(\"/\") if p]\nif urlparse(url).netloc and len(parts) < 2:\n    raise ValueError(f\"URL lacks owner/repo: {url}\")","typeGuard":"def url_has_repo_id(url: str) -> bool:\n    if \"://\" not in url:\n        return \"/\" in url.strip(\"/\")  # owner/repo form\n    return len([p for p in urlparse(url).path.split(\"/\") if p]) >= 2","tryCatchPattern":null,"preventionTips":["Validate URLs contain owner/repo before startup","Prefer the 'owner/repo' shorthand in configs"],"tags":["huggingface","weights","malformed-url"],"backgroundTag":"malformed-repository-url","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}