{"record":{"id":"316b2652be4378c1","repo":"opendatalab/MinerU","slug":"model-source-auto-is-only-supported-for-internal-d","errorCode":null,"errorMessage":"model source auto is only supported for internal default detection or explicit download command selection.","messagePattern":"model source auto is only supported for internal default detection or explicit download command selection\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/utils/models_download_utils.py","lineNumber":237,"sourceCode":"                \"or set it to huggingface/modelscope/local.\"\n            )\n    if model_source is None:\n        model_source = get_configured_model_source()\n    if model_source is None:\n        model_source = \"auto\"\n        allow_auto = True\n\n    if not isinstance(model_source, str):\n        logger.warning(f\"Unsupported model source type: {type(model_source)}, fallback to auto.\")\n        model_source = \"auto\"\n        allow_auto = True\n\n    normalized_model_source = model_source.strip().lower()\n    if normalized_model_source == \"local\":\n        return \"local\"\n    if normalized_model_source == \"auto\":\n        if not allow_auto:\n            raise ValueError(\n                \"model source auto is only supported for internal default detection \"\n                \"or explicit download command selection.\"\n            )\n        resolved_model_source = resolve_auto_model_source()\n        persist_resolved_model_source(resolved_model_source)\n        return resolved_model_source\n    if normalized_model_source in REMOTE_MODEL_SOURCES:\n        return normalized_model_source\n\n    logger.warning(f\"Unsupported model source: {model_source}, fallback to auto.\")\n    resolved_model_source = resolve_auto_model_source()\n    persist_resolved_model_source(resolved_model_source)\n    return resolved_model_source\n\n\n@lru_cache(maxsize=None)\ndef _snapshot_download_cached(model_source: str, repo_mode: str, repo: str, relative_path: str) -> str:\n    \"\"\"按进程缓存远端 snapshot_download 结果，减少重复缓存检查和 Fetching 日志。\"\"\"","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/utils/models_download_utils.py#L219-L255","documentation":"Raised by resolve_model_source() when the model source resolves to the literal 'auto' but auto-detection is not permitted at that call site (allow_auto is False). 'auto' is only legal when it comes from MineRU's own internal default (no configured source) or from an explicit download-command selection; an explicit 'auto' string coming from the config file reaches this branch without allow_auto and is rejected. This mirrors error 144 but for config-file-supplied values rather than the env var.","triggerScenarios":"Setting \"model-source\": \"auto\" (or a value that normalizes to auto) in the config file so get_configured_model_source() returns it, then calling resolve_model_source() with allow_auto=False — the default for library callers.","commonSituations":"The mineru.json config was hand-edited or migrated with model-source: auto left in; documentation examples show auto as a config value; a downgrade/upgrade between versions changed whether config-file auto is accepted.","solutions":["Remove the model-source key from the config file so MineRU falls back to internal detection (which sets allow_auto=True) and persists the resolved source.","Or set a concrete value in the config: \"model-source\": \"huggingface\" | \"modelscope\" | \"local\".","Ensure MINERU_MODEL_SOURCE is not set to auto either (see the companion env-var error).","After fixing, let the first download run once — detection picks a reachable mirror and persists it, so subsequent runs skip detection."],"exampleFix":"// before (mineru.json)\n{ \"model-source\": \"auto\" }\n\n// after\n{ \"model-source\": \"modelscope\" }\n// or simply omit the key","handlingStrategy":"validation","validationCode":"import json, os\ncfg = json.load(open(os.path.expanduser('~/mineru.json')))\nsrc = cfg.get('model-source')\nassert src is None or str(src).strip().lower() in {'huggingface', 'modelscope', 'local'}, \\\n    f'model-source={src!r} invalid; remove the key or use a concrete source'","typeGuard":"def valid_config_model_source(cfg: dict) -> bool:\n    src = cfg.get('model-source')\n    return src is None or (isinstance(src, str) and src.strip().lower() in {'huggingface', 'modelscope', 'local'})","tryCatchPattern":"try:\n    resolve_model_source()\nexcept ValueError as e:\n    if 'auto is only supported' in str(e):\n        raise SystemExit('Remove \"model-source\": \"auto\" from mineru.json; omit the key or set a concrete source')\n    raise","preventionTips":["Validate the config file's model-source key at deploy time against the explicit allow-list.","Omit model-source entirely when you want detection; absence is the supported way to say auto.","After a first successful auto-detected download, read the persisted source and pin it in config for reproducible deployments."],"tags":["config","model-download","mineru"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}