opendatalab/MinerU · error · HTTPException
Language {lang} not supported. Allowed values: {allowed_valu
Error message
Language {lang} not supported. Allowed values: {allowed_values} What it means
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.
Source
Thrown at mineru/cli/api_request.py:89
return validate_public_backend(backend)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
def validate_parse_effort(effort: str) -> str:
"""校验公开 API 允许的 hybrid effort,避免非法值进入解析链路。"""
try:
return validate_public_effort(effort)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
def validate_parse_lang_list(lang_list: list[str]) -> list[str]:
"""校验公开 API 允许的 OCR 语言列表,避免旧语言入口进入解析链路。"""
try:
return validate_public_ocr_lang_list(lang_list)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
async def parse_request_form(
request: Request,
files: Annotated[
list[UploadFile],
File(
description="Upload PDF, image, DOCX, PPTX, or XLSX files for parsing",
json_schema_extra=SWAGGER_UI_FILE_ARRAY_SCHEMA_EXTRA,
),
],
lang_list: Annotated[
list[str],
Form(
description=format_public_ocr_lang_description(),
json_schema_extra=PUBLIC_OCR_LANGUAGE_SCHEMA_EXTRA,
),
] = ["ch"],View on GitHub (pinned to 4fe4bde114)
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
Example fix
# before
data = {'parse_method': 'ocr', 'lang_list': ['chi_sim', 'eng']}
# after
data = {'parse_method': 'ocr', 'lang_list': ['ch', 'en']} Defensive patterns
Strategy: validation
Validate before calling
# Probe once and cache the server's supported languages
cfg = requests.get(f"{base_url}/parse-config", timeout=10).json() # or read from /docs
allowed_langs = set(cfg.get("lang_list", ["ch", "en"]))
lang_list = [l.strip().lower() for l in lang_list if l.strip().lower() in allowed_langs] Type guard
def is_valid_lang_list(v: list[str]) -> bool:
return isinstance(v, list) and all(isinstance(x, str) and x.strip().lower() in {"ch", "en"} for x in v) Try / catch
try:
resp = requests.post(url, files=files, data={"lang_list": json.dumps(langs)}, timeout=60)
resp.raise_for_status()
except requests.HTTPError as e:
if e.response.status_code == 400 and "not supported" in e.response.text:
langs = ["ch", "en"] # safe default; retry once
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid parse_method. Allowed values: {allowed_values}
- Invalid backend. Allowed values: {allowed_values}
- Invalid effort. Allowed values: {allowed_values}
- Language {lang} not supported. Allowed values: {PUBLIC_OCR_L
- Language {lang} not supported
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/ef77d7621f9f7600.
Report an issue: GitHub.