{"record":{"id":"85fa8cecda66e9f1","repo":"opendatalab/MinerU","slug":"invalid-parse-method-allowed-values-allowed-val","errorCode":null,"errorMessage":"Invalid parse_method. Allowed values: {allowed_values}","messagePattern":"Invalid parse_method\\. Allowed values: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"mineru/cli/api_request.py","lineNumber":58,"sourceCode":"    table_enable: bool\n    image_analysis: bool\n    server_url: Optional[str]\n    return_md: bool\n    return_middle_json: bool\n    return_model_output: bool\n    return_content_list: bool\n    return_images: bool\n    response_format_zip: bool\n    return_original_file: bool\n    client_side_output_generation: bool\n    start_page_id: int\n    end_page_id: int\n\n\ndef validate_parse_method(parse_method: str) -> str:\n    \"\"\"校验公开 API 允许的 PDF 解析方式，避免各入口维护不同规则。\"\"\"\n    if parse_method not in ALLOWED_PARSE_METHODS:\n        raise HTTPException(\n            status_code=400,\n            detail=(\n                \"Invalid parse_method. Allowed values: \"\n                + \", \".join(sorted(ALLOWED_PARSE_METHODS))\n            ),\n        )\n    return parse_method\n\n\ndef validate_parse_backend(backend: str) -> str:\n    \"\"\"校验公开 API 允许的解析后端，避免旧入口名进入下游执行链路。\"\"\"\n    try:\n        return validate_public_backend(backend)\n    except ValueError as exc:\n        raise HTTPException(status_code=400, detail=str(exc)) from exc\n\n\ndef validate_parse_effort(effort: str) -> str:","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/cli/api_request.py#L40-L76","documentation":"HTTP 400 raised by the FastAPI parse endpoint's validate_parse_method(): the parse_method form field must be one of {'auto','txt','ocr'} (ALLOWED_PARSE_METHODS in mineru/cli/api_request.py). It exists so every public entry enforces one rule set instead of each endpoint drifting.","triggerScenarios":"POSTing to /file_parse (or the equivalent endpoint) with parse_method='pipeline', 'vlm', 'hybrid', 'TXT', or omitting an unrecognized value; old clients that used backend names as parse_method.","commonSituations":"Version migration: pre-2.x mineru API accepted method names that are now backends; scripts built against older /docs swagger; language confusion between 'backend' and 'parse_method' parameters.","solutions":["Use one of: auto, txt, ocr (exact lowercase) for parse_method","To select the engine, use the separate backend parameter (pipeline, vlm-engine, hybrid-engine, ...) not parse_method","Check the live schema at the server's /docs endpoint for the current field names","Upgrade the client script to the mineru version matching the server"],"exampleFix":"# before\ncurl -F file=@doc.pdf -F parse_method=vlm http://localhost:8000/file_parse\n\n# after\ncurl -F file=@doc.pdf -F parse_method=auto -F backend=vlm-engine http://localhost:8000/file_parse","handlingStrategy":"validation","validationCode":"from mineru.cli.api_request import ALLOWED_PARSE_METHODS  # {'auto','txt','ocr'}\n\nparse_method = parse_method.strip().lower()\nif parse_method not in ALLOWED_PARSE_METHODS:\n    raise SystemExit(f\"parse_method must be one of {sorted(ALLOWED_PARSE_METHODS)}\")","typeGuard":"def is_valid_parse_method(v: str) -> bool:\n    return isinstance(v, str) and v.strip().lower() in {\"auto\", \"txt\", \"ocr\"}","tryCatchPattern":"try:\n    resp = requests.post(url, files=files, data={\"parse_method\": pm, \"backend\": b}, timeout=60)\n    resp.raise_for_status()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400 and \"parse_method\" in e.response.text:\n        pm = \"auto\"  # retry with the safe default\n        resp = requests.post(url, files=files, data={\"parse_method\": pm, \"backend\": b}, timeout=60)\n    else:\n        raise","preventionTips":["Check the server /docs enum before writing client code","Keep parse_method (auto/txt/ocr) and backend (engine choice) in separate variables — never interchange","Pin client and server mineru versions together"],"tags":["api","http-400","validation","parse-method"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}