{"record":{"id":"12c80a157505eff2","repo":"sgl-project/sglang","slug":"unsupported-hugging-face-weight-url-source-r","errorCode":null,"errorMessage":"Unsupported Hugging Face weight URL: {source!r}","messagePattern":"Unsupported Hugging Face weight URL: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/weights/source.py","lineNumber":93,"sourceCode":"\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\":\n        subfolder = _validate_relative_hub_path(tail, \"subfolder\") if tail else None\n        return WeightSource(\n            original=source,\n            kind=\"huggingface\",\n            repo_id=repo_id,\n            revision=selected_revision,\n            subfolder=subfolder,\n        )\n    if not tail:\n        raise ValueError(f\"Hugging Face weight URL has no filename: {source!r}\")\n    return WeightSource(\n        original=source,\n        kind=\"huggingface\",","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/weights/source.py#L75-L111","documentation":"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.","triggerScenarios":"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).","commonSituations":"Copying a commits/history page URL from the Hub, or truncating a tree/blob URL so the revision segment is missing.","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"],"exampleFix":"# before\nparse_weight_source(\"https://huggingface.co/org/repo/commits/main\")\n# after\nparse_weight_source(\"https://huggingface.co/org/repo/tree/main\")","handlingStrategy":"type-guard","validationCode":"parts = [p for p in urlparse(url).path.split(\"/\") if p]\naction = parts[2] if len(parts) > 2 else None\nif action is not None and (action not in (\"tree\", \"blob\", \"resolve\") or len(parts) < 4):\n    url = f\"https://huggingface.co/{parts[0]}/{parts[1]}\"  # reduce to repo root","typeGuard":"def is_supported_hf_url_shape(url: str) -> bool:\n    parts = [p for p in urlparse(url).path.split(\"/\") if p]\n    if len(parts) <= 2:\n        return True\n    return parts[2] in (\"tree\", \"blob\", \"resolve\") and len(parts) >= 4","tryCatchPattern":null,"preventionTips":["Copy URLs from the Hub file browser (Files and versions tab)","Normalize any weight URL down to owner/repo plus explicit subfolder/revision args"],"tags":["huggingface","weights","unsupported-url-shape"],"backgroundTag":"unsupported-url-shape","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}