{"record":{"id":"32e283532c29f11e","repo":"sgl-project/sglang","slug":"exc","errorCode":null,"errorMessage":"{exc}","messagePattern":"\\{exc\\}","errorType":"exception","errorClass":"EntryNotFoundError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py","lineNumber":1161,"sourceCode":"    local_dir: Optional[Union[str, Path]] = None,\n    **kwargs,\n) -> str:\n    \"\"\"Unified hf_hub_download that supports both Hugging Face Hub and ModelScope.\"\"\"\n    if envs.SGLANG_USE_MODELSCOPE.get():\n        from modelscope import model_file_download\n        from modelscope.hub.errors import NotExistError\n\n        try:\n            return model_file_download(\n                model_id=repo_id,\n                file_path=filename,\n                local_dir=str(local_dir) if local_dir is not None else None,\n                **kwargs,\n            )\n        except NotExistError as exc:\n            # Keep the Hugging Face-compatible exception contract used by\n            # maybe_download_model_index for repositories without model_index.json.\n            raise EntryNotFoundError(str(exc)) from exc\n    else:\n        from huggingface_hub import hf_hub_download as _hf_hub_download\n\n        return _hf_hub_download(\n            repo_id=repo_id,\n            filename=filename,\n            local_dir=local_dir,\n            **kwargs,\n        )\n\n\ndef snapshot_download(\n    repo_id: str,\n    local_dir: Optional[Union[str, Path]] = None,\n    ignore_patterns: Optional[Union[list[str], str]] = None,\n    allow_patterns: Optional[Union[list[str], str]] = None,\n    local_files_only: bool = False,\n    max_workers: int = 8,","sourceCodeStart":1143,"sourceCodeEnd":1179,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py#L1143-L1179","documentation":"hf_hub_download wraps a ModelScope NotExistError into EntryNotFoundError to keep the Hugging Face-compatible exception contract: the requested file does not exist in the given repository. This mirrors huggingface_hub.EntryNotFoundError so callers can handle missing files uniformly across hubs.","triggerScenarios":"Calling hf_hub_download (directly or via get_is_diffusion_model, download_and_cache_hf_file, resolve_transformer_safetensors_to_load) with a repo_id/filename combination where the file is absent — e.g. looking for model_index.json in a non-diffusers repo, or a wrong filename/subfolder.","commonSituations":"Probing repos for optional files (model_index.json, config.json) with try/except, wrong subfolder paths for sharded weights, renamed files upstream, repos that are pure transformers vs diffusers layouts.","solutions":["Verify the exact filename (and subfolder) exists in the repo with huggingface-cli ls-files or the web UI","If the file is optional, catch EntryNotFoundError and fall back to the next candidate","Use the correct repo variant (e.g. the diffusion repo rather than the base LLM repo)","If the file is sharded, resolve the shard list from the index instead of a single filename"],"exampleFix":"// before\nf = hf_hub_download(repo_id, \"model_index.json\")\n// after\ntry:\n    f = hf_hub_download(repo_id, \"model_index.json\")\nexcept EntryNotFoundError:\n    f = None  # not a diffusers-style repo","handlingStrategy":"try-catch","validationCode":"from huggingface_hub import HfApi\nfiles = set(HfApi().list_repo_files(repo_id))\nif filename not in files:\n    # choose fallback before calling","typeGuard":null,"tryCatchPattern":"try:\n    path = hf_hub_download(repo_id, filename)\nexcept EntryNotFoundError:\n    path = fallback_resolution(repo_id)","preventionTips":["Probe optional files with try/except EntryNotFoundError","List repo files once and cache the result","Double-check subfolder paths for sharded weights"],"tags":["file-not-found","huggingface","modelscope"],"backgroundTag":"file-not-found-in-repo","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}