{"record":{"id":"76d3d013244f37be","repo":"opendatalab/MinerU","slug":"model-source-env-var-auto-is-not-supported-unse","errorCode":null,"errorMessage":"{MODEL_SOURCE_ENV_VAR}=auto is not supported. Unset {MODEL_SOURCE_ENV_VAR} to use auto detection once, or set it to huggingface/modelscope/local.","messagePattern":"(.+?)=auto is not supported\\. Unset (.+?) to use auto detection once, or set it to huggingface/modelscope/local\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/utils/models_download_utils.py","lineNumber":216,"sourceCode":"            )\n            if 200 <= response.status_code < 400:\n                return \"huggingface\"\n            last_error = f\"status_code={response.status_code}\"\n        except Exception as exc:\n            last_error = str(exc)\n\n    logger.warning(\n        f\"Failed to access {HUGGINGFACE_MODELS_PAGE_URL}: {last_error}, fallback to modelscope.\"\n    )\n    return \"modelscope\"\n\n\ndef resolve_model_source(model_source: str | None = None, allow_auto: bool = False) -> str:\n    \"\"\"将环境变量或配置文件中的模型来源解析为实际可下载的来源。\"\"\"\n    if model_source is None:\n        model_source = os.getenv(MODEL_SOURCE_ENV_VAR)\n        if isinstance(model_source, str) and model_source.strip().lower() == \"auto\":\n            raise ValueError(\n                f\"{MODEL_SOURCE_ENV_VAR}=auto is not supported. \"\n                f\"Unset {MODEL_SOURCE_ENV_VAR} to use auto detection once, \"\n                \"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\"","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/utils/models_download_utils.py#L198-L234","documentation":"Raised by resolve_model_source() in MineRU's model download utilities when the environment variable MINERU_MODEL_SOURCE is explicitly set to the literal 'auto'. 'auto' is a special internal sentinel meaning 'detect once and persist the result'; pinning it via the environment is disallowed because it would make every call re-run network detection instead of using the persisted source. Valid explicit values are huggingface, modelscope, or local.","triggerScenarios":"Exporting MINERU_MODEL_SOURCE=auto (any case, surrounding whitespace tolerated) and then calling any model-download path (e.g. auto_download_and_get_model_root_path) that calls resolve_model_source().","commonSituations":"A user copies an example that lists auto among possible values and exports it 'to be safe'; a CI matrix sets the variable for every job including the auto-detection one; a migration from an older version where auto was accepted as an env value.","solutions":["Unset the variable to get one-time auto detection: unset MINERU_MODEL_SOURCE — detection runs, resolves to huggingface or modelscope, and persists the result.","Or pin an explicit source: export MINERU_MODEL_SOURCE=modelscope (or huggingface / local).","Search deployment scripts, Docker ENV lines, and CI variables for MINERU_MODEL_SOURCE=auto and remove or replace it."],"exampleFix":"# before\nexport MINERU_MODEL_SOURCE=auto\n\n# after\nunset MINERU_MODEL_SOURCE\n# or: export MINERU_MODEL_SOURCE=modelscope","handlingStrategy":"validation","validationCode":"import os\nval = os.getenv('MINERU_MODEL_SOURCE')\nif val is not None and val.strip().lower() == 'auto':\n    os.environ.pop('MINERU_MODEL_SOURCE')  # let MineRU auto-detect once\nassert os.getenv('MINERU_MODEL_SOURCE', 'huggingface') in {'huggingface', 'modelscope', 'local'}","typeGuard":"def is_explicit_model_source(val: str | None) -> bool:\n    return val is None or val.strip().lower() in {'huggingface', 'modelscope', 'local'}","tryCatchPattern":"try:\n    root = auto_download_and_get_model_root_path(rel)\nexcept ValueError as e:\n    if 'MINERU_MODEL_SOURCE=auto' in str(e):\n        os.environ.pop('MINERU_MODEL_SOURCE', None)\n        root = auto_download_and_get_model_root_path(rel)\n    else:\n        raise","preventionTips":["Only ever set MINERU_MODEL_SOURCE to huggingface/modelscope/local; leave it unset for auto detection.","Grep CI/CD variable definitions and Dockerfiles for '=auto' before shipping.","Remember auto detection result is persisted — after one successful run you can pin the resolved value explicitly."],"tags":["environment-variable","model-download","config","mineru"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}