{"record":{"id":"12778026244c5217","repo":"opendatalab/MinerU","slug":"language-lang-not-supported-127780","errorCode":null,"errorMessage":"Language {lang} not supported","messagePattern":"Language (.+?) not supported","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/utils/ocr_language.py","lineNumber":156,"sourceCode":"    supported_langs=None,\n) -> str:\n    \"\"\"将 OCR 语言参数归一为模型配置 key，保留内部 seal 与语系短码能力。\"\"\"\n    normalized_lang = lang or \"ch\"\n    if device == \"cpu\" and normalized_lang == \"seal\":\n        normalized_lang = \"seal_lite\"\n    elif normalized_lang in _CH_LANG_ALIASES:\n        normalized_lang = \"ch\"\n    elif normalized_lang in _EAST_SLAVIC_LANG_ALIASES:\n        normalized_lang = \"east_slavic\"\n    elif normalized_lang in _ARABIC_LANG_ALIASES:\n        normalized_lang = \"arabic\"\n    elif normalized_lang in _CYRILLIC_LANG_ALIASES:\n        normalized_lang = \"cyrillic\"\n    elif normalized_lang in _DEVANAGARI_LANG_ALIASES:\n        normalized_lang = \"devanagari\"\n\n    if supported_langs is not None and normalized_lang not in supported_langs:\n        raise ValueError(f\"Language {lang} not supported\")\n    return normalized_lang\n","sourceCodeStart":138,"sourceCodeEnd":158,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/utils/ocr_language.py#L138-L158","documentation":"Raised by the internal normalize_lang() when a language string, after alias normalization (e.g. east-slavic/arabic/cyrillic/devanagari alias groups collapsing to canonical keys, Chinese aliases to 'ch'), is still not present in the caller-supplied supported_langs set. Unlike the public-API check (error 150), the allow-list here is dynamic: supported_langs reflects the languages the loaded OCR model actually supports (e.g. the Anglo-Slavic mixed model accepts only ch/en/east_slavic). The raw, un-normalized lang appears in the message.","triggerScenarios":"Passing lang='french' (or any language outside the active model's supported_langs) into pipeline code that calls normalize_lang with the loaded model's language set — e.g. using the default ch/en model and requesting 'french' or 'japan'.","commonSituations":"Assuming all PaddleOCR languages are available because the docs mention them, while the loaded model variant supports only a subset; switching OCR model files without updating the language config; a config file carries a language valid for a previous MineRU version but no longer in the active set.","solutions":["Match the language to the loaded model: with the standard ch/east_slavic models use 'ch', 'en', 'east_slavic' (aliases accepted); for other languages you need a model variant whose supported_langs includes them.","Pre-check your language list against the same supported set the pipeline uses (inspect the model config / PUBLIC_OCR_LANGUAGES for the public API) before starting a long parse job.","If multiple languages are needed, ensure every entry in lang_list passes — one bad entry aborts the whole list."],"exampleFix":"# before\nresult = pipeline_backend.parse(pdf_bytes, lang_list=['fr'])  # ValueError: Language fr not supported\n\n# after\nresult = pipeline_backend.parse(pdf_bytes, lang_list=['ch', 'en'])","handlingStrategy":"validation","validationCode":"from mineru.utils.ocr_language import normalize_lang\n\nSUPPORTED = {'ch', 'en', 'east_slavic'}  # mirror the loaded model's supported_langs\nlangs = ['ch', 'en', 'east_slavic']\nfor l in langs:\n    normalized = normalize_lang(l)  # raises if alias table rejects it\n    assert normalized in SUPPORTED, f'{l} -> {normalized} not supported by loaded model'","typeGuard":"from typing import TypeGuard\n\ndef is_supported_lang(lang: object, supported: set[str]) -> TypeGuard[str]:\n    if not isinstance(lang, str):\n        return False\n    try:\n        return normalize_lang(lang, supported_langs=supported) in supported\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    normalized = normalize_lang(lang, supported_langs=SUPPORTED)\nexcept ValueError:\n    # drop the language with a warning instead of aborting the whole document\n    logger.warning('unsupported OCR language %s skipped', lang)\n    normalized = None","preventionTips":["Keep a single source of truth for the active model's supported languages and validate every request against it.","Run normalize_lang over the full lang_list before starting the parse; one bad entry otherwise aborts mid-job.","When swapping OCR model variants, re-derive the supported set instead of hardcoding it in multiple places."],"tags":["ocr","validation","language","mineru"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}