{"record":{"id":"b522cac7f61a20b2","repo":"opendatalab/MinerU","slug":"unsupported-repo-mode-repo-mode-must-be-pipel","errorCode":null,"errorMessage":"Unsupported repo_mode: {repo_mode}, must be 'pipeline' or 'vlm'","messagePattern":"Unsupported repo_mode: (.+?), must be 'pipeline' or 'vlm'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/utils/models_download_utils.py","lineNumber":272,"sourceCode":"def _snapshot_download_cached(model_source: str, repo_mode: str, repo: str, relative_path: str) -> str:\n    \"\"\"按进程缓存远端 snapshot_download 结果，减少重复缓存检查和 Fetching 日志。\"\"\"\n    if model_source == \"huggingface\":\n        snapshot_download = hf_snapshot_download\n    elif model_source == \"modelscope\":\n        snapshot_download = ms_snapshot_download\n    else:\n        raise ValueError(f\"未知的仓库类型: {model_source}\")\n\n    if repo_mode == 'pipeline':\n        cache_dir = snapshot_download(repo, allow_patterns=[relative_path, relative_path + \"/*\"])\n    elif repo_mode == 'vlm':\n        # VLM 整仓下载和局部路径下载都参与缓存，但保持原有 allow_patterns 行为。\n        if relative_path == \"/\":\n            cache_dir = snapshot_download(repo)\n        else:\n            cache_dir = snapshot_download(repo, allow_patterns=[relative_path, relative_path + \"/*\"])\n    else:\n        raise ValueError(f\"Unsupported repo_mode: {repo_mode}, must be 'pipeline' or 'vlm'\")\n\n    if cache_dir:\n        persist_downloaded_model_config(model_source, repo_mode, cache_dir)\n    return cache_dir\n\n\ndef auto_download_and_get_model_root_path(relative_path: str, repo_mode='pipeline') -> str:\n    \"\"\"\n    支持文件或目录的可靠下载。\n    - 如果输入文件: 返回本地文件绝对路径\n    - 如果输入目录: 返回本地缓存下与 relative_path 同结构的相对路径字符串\n    :param repo_mode: 指定仓库模式，'pipeline' 或 'vlm'\n    :param relative_path: 文件或目录相对路径\n    :return: 本地文件绝对路径或相对路径\n    \"\"\"\n    model_source = resolve_model_source()\n\n    if model_source == 'local':","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/utils/models_download_utils.py#L254-L290","documentation":"Raised in the model snapshot-download helper when the repo_mode argument is neither 'pipeline' nor 'vlm'. repo_mode selects which Hugging Face / ModelScope repository layout to download from (pipeline models vs. the VLM whole-repo), so any other string cannot be mapped to a repository. The value usually comes from a caller-supplied parameter defaulting to 'pipeline'.","triggerScenarios":"Calling auto_download_and_get_model_root_path(relative_path, repo_mode=...) — or the internal snapshot download helper — with a typo or third value such as 'VLM', 'pipelines', 'backend', or None.","commonSituations":"A caller passes a backend name intended for a different API (e.g. 'vlm-engine' or 'vlm-transformers') where the plain 'vlm' is expected; case or pluralization typos; passing a variable that is None after a failed lookup upstream.","solutions":["Pass exactly 'pipeline' or 'vlm' (lowercase) as repo_mode.","If the value comes from a user/config field, normalize it before calling: value.strip().lower() and validate against {'pipeline', 'vlm'} with an early, clear error.","Check the calling code — if you intended the VLM backend, the download layer wants the literal 'vlm', not a backend identifier."],"exampleFix":"# before\nroot = auto_download_and_get_model_root_path('models/README.md', repo_mode='VLM')\n\n# after\nroot = auto_download_and_get_model_root_path('models/README.md', repo_mode='vlm')","handlingStrategy":"type-guard","validationCode":"REPO_MODES = {'pipeline', 'vlm'}\nmode = 'vlm'\nassert mode in REPO_MODES, f'repo_mode must be one of {REPO_MODES}'","typeGuard":"def is_repo_mode(value: object) -> bool:\n    return isinstance(value, str) and value in {'pipeline', 'vlm'}","tryCatchPattern":"try:\n    cache = download_model(path, repo_mode=mode)\nexcept ValueError as e:\n    if 'Unsupported repo_mode' in str(e):\n        raise SystemExit(f'Bad repo_mode {mode!r}; use pipeline or vlm') from e\n    raise","preventionTips":["Centralize repo_mode as an Enum/Literal in your wrapper instead of passing raw strings.","Normalize external inputs (strip().lower()) and validate against {'pipeline','vlm'} at the API boundary."],"tags":["model-download","validation","mineru"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}