{"record":{"id":"5f2f08a3cf67da81","repo":"sgl-project/sglang","slug":"only-huggingface-co-weight-urls-are-supported-use","errorCode":null,"errorMessage":"Only huggingface.co weight URLs are supported; use a local path or an owner/repo reference for other sources","messagePattern":"Only huggingface\\.co weight URLs are supported; use a local path or an owner/repo reference for other sources","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/weights/source.py","lineNumber":71,"sourceCode":"    pure_path = PurePosixPath(normalized)\n    if not path or pure_path.is_absolute() or \"..\" in pure_path.parts:\n        raise ValueError(f\"Invalid Hugging Face {field_name}: {path!r}\")\n    return normalized\n\n\ndef _merge_revision(url_revision: str | None, revision: str | None) -> str | None:\n    if url_revision is not None and revision is not None and url_revision != revision:\n        raise ValueError(\n            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,","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/weights/source.py#L53-L89","documentation":"Raised by _parse_huggingface_url when a URL-style weight source's host is not huggingface.co (or www.huggingface.co). Only huggingface.co URLs are parsed; other hosts must be referenced differently.","triggerScenarios":"Calling parse_weight_source with e.g. https://modelscope.cn/org/repo or https://my-mirror.com/org/repo.","commonSituations":"Using a HF mirror/CDN domain, a ModelScope or S3 URL, or an internal artifact store while the loader only supports huggingface.co.","solutions":["Download or export the weights locally and pass a local filesystem path instead","Use the owner/repo identifier form if the repo is (mirrored to) Hugging Face","Switch the host to huggingface.co if the URL was merely mistyped"],"exampleFix":"# before\nparse_weight_source(\"https://modelscope.cn/org/repo\")\n# after\nparse_weight_source(\"/data/weights/org-repo\")  # local snapshot\n# or\nparse_weight_source(\"org/repo\")","handlingStrategy":"type-guard","validationCode":"from urllib.parse import urlparse\nnetloc = urlparse(source).netloc.lower()\nif \"://\" in source and netloc not in (\"huggingface.co\", \"www.huggingface.co\"):\n    source = download_to_local(source)  # or map to owner/repo","typeGuard":"def is_supported_weight_source(source: str) -> bool:\n    if \"://\" not in source:\n        return True  # local path or owner/repo\n    return urlparse(source).netloc.lower() in (\"huggingface.co\", \"www.huggingface.co\")","tryCatchPattern":"try:\n    src = parse_weight_source(source)\nexcept ValueError as e:\n    if \"Only huggingface.co\" in str(e):\n        src = parse_weight_source(mirror_to_local_path(source))\n    else:\n        raise","preventionTips":["Resolve mirror URLs (hf-mirror, modelscope) to local snapshots before parsing","Standardize configs on owner/repo or local paths"],"tags":["huggingface","weights","unsupported-host","url-parsing"],"backgroundTag":"unsupported-download-host","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}