{"record":{"id":"ef77d7621f9f7600","repo":"opendatalab/MinerU","slug":"language-lang-not-supported-allowed-values-al","errorCode":null,"errorMessage":"Language {lang} not supported. Allowed values: {allowed_values}","messagePattern":"Language (.+?) not supported\\. Allowed values: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"mineru/cli/api_request.py","lineNumber":89,"sourceCode":"        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:\n    \"\"\"校验公开 API 允许的 hybrid effort，避免非法值进入解析链路。\"\"\"\n    try:\n        return validate_public_effort(effort)\n    except ValueError as exc:\n        raise HTTPException(status_code=400, detail=str(exc)) from exc\n\n\ndef validate_parse_lang_list(lang_list: list[str]) -> list[str]:\n    \"\"\"校验公开 API 允许的 OCR 语言列表，避免旧语言入口进入解析链路。\"\"\"\n    try:\n        return validate_public_ocr_lang_list(lang_list)\n    except ValueError as exc:\n        raise HTTPException(status_code=400, detail=str(exc)) from exc\n\n\nasync def parse_request_form(\n    request: Request,\n    files: Annotated[\n        list[UploadFile],\n        File(\n            description=\"Upload PDF, image, DOCX, PPTX, or XLSX files for parsing\",\n            json_schema_extra=SWAGGER_UI_FILE_ARRAY_SCHEMA_EXTRA,\n        ),\n    ],\n    lang_list: Annotated[\n        list[str],\n        Form(\n            description=format_public_ocr_lang_description(),\n            json_schema_extra=PUBLIC_OCR_LANGUAGE_SCHEMA_EXTRA,\n        ),\n    ] = [\"ch\"],","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/cli/api_request.py#L71-L107","documentation":"HTTP 400 raised by validate_parse_lang_list(): each OCR language code in lang_list is validated by validate_public_ocr_lang_list and unsupported codes are rejected with the allowed list in the message. This stops old/invalid language entries (e.g. deprecated codes) from entering the OCR chain.","triggerScenarios":"POSTing lang_list=['ch'], ['chi_sim'], ['EN'], or an unknown code together with parse_method that triggers OCR; empty or malformed arrays also fail downstream validation.","commonSituations":"Codes copied from tesseract names ('chi_sim','eng') instead of mineru's codes ('ch','en'); uppercase variants; users migrating from other OCR tools whose lang tags differ.","solutions":["Use the codes listed in the error message (commonly 'ch' and 'en' style short codes)","Do not use tesseract-style codes like chi_sim or deu","Match casing exactly (lowercase)","Omit lang_list to use the server default rather than guessing codes"],"exampleFix":"# before\ndata = {'parse_method': 'ocr', 'lang_list': ['chi_sim', 'eng']}\n\n# after\ndata = {'parse_method': 'ocr', 'lang_list': ['ch', 'en']}","handlingStrategy":"validation","validationCode":"# Probe once and cache the server's supported languages\ncfg = requests.get(f\"{base_url}/parse-config\", timeout=10).json()  # or read from /docs\nallowed_langs = set(cfg.get(\"lang_list\", [\"ch\", \"en\"]))\nlang_list = [l.strip().lower() for l in lang_list if l.strip().lower() in allowed_langs]","typeGuard":"def is_valid_lang_list(v: list[str]) -> bool:\n    return isinstance(v, list) and all(isinstance(x, str) and x.strip().lower() in {\"ch\", \"en\"} for x in v)","tryCatchPattern":"try:\n    resp = requests.post(url, files=files, data={\"lang_list\": json.dumps(langs)}, timeout=60)\n    resp.raise_for_status()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400 and \"not supported\" in e.response.text:\n        langs = [\"ch\", \"en\"]  # safe default; retry once\n    else:\n        raise","preventionTips":["Use mineru's short codes (ch, en), not tesseract names (chi_sim, eng)","Omit lang_list to take the server default","Parse the allowed-values list out of the 400 body and cache it for the session"],"tags":["api","http-400","validation","ocr","language"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}