{"record":{"id":"66c072099a537e9b","repo":"zylon-ai/private-gpt","slug":"no-ocr-languages-specified","errorCode":null,"errorMessage":"No OCR languages specified.","messagePattern":"No OCR languages specified\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/readers/docling/common.py","lineNumber":29,"sourceCode":"\n# Constants\nDEFAULT_IMAGE_PLACEHOLDER = \"<!-- image -->\"\nEMBEDDED_IMAGES = settings().docling.image_mode == \"embedded\"\nIMAGE_DUMMY = IMAGE_PLACEHOLDER\nIMAGE_RESOLUTION_SCALE = 2.0\n\nPAGE_PLACEHOLDER = \"\\n<!-- page -->\\n\"\n\n\ndef get_ocr_langs() -> list[str] | None:\n    \"\"\"Get the OCR languages.\n\n    Returns:\n        list[str]: List of OCR languages.\n    \"\"\"\n    langs: list[str] | None = settings().docling.langs\n    if not langs:\n        raise ValueError(\"No OCR languages specified.\")\n    match settings().docling.ocr_model:\n        case \"easyocr\":\n            langs = [convert_to_easyocr_lang(lang) for lang in langs]\n        case \"tesseract\":\n            langs = [convert_to_tesseract_lang(lang) for lang in langs]\n        case \"rapidocr\":\n            langs = [convert_to_rapidocr_lang(lang) for lang in langs]\n        case \"ocrmac\":\n            langs = [convert_to_ocrmac_lang(lang) for lang in langs]\n        case _:\n            raise ValueError(f\"OCR model {settings().docling.ocr_model} not supported\")\n    return langs\n\n\nasync def calculate_file_priority(\n    file_bytes: bytes, pages: int | None = None, **kwargs: Any\n) -> int:\n    \"\"\"Calculate processing priority based on file size and page count.","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/readers/docling/common.py#L11-L47","documentation":"Raised by get_ocr_langs() in private_gpt/components/readers/docling/common.py when settings().docling.langs is empty/None. OCR language lists are needed to build the conversion options sent to Docling (ocr_lang), and this function deliberately refuses to guess a default: no langs means OCR cannot be configured, so it aborts before any request is made.","triggerScenarios":"Any docling conversion path that calls get_ocr_langs() (option building for OCR-enabled conversion) while settings.docling.langs is unset or an empty list in settings.yaml. Fires before any network I/O, at payload-construction time.","commonSituations":"A settings.yaml that customizes the docling block (e.g., sets use_ocr: true, ocr_model) but omits langs; deployments relying on a default that does not exist for langs; trimming config down for a minimal install and accidentally dropping the langs key.","solutions":["Add langs to the docling section of settings.yaml, e.g. langs: [en] or langs: [en, es].","If you do not want OCR at all, set use_ocr: false so the OCR language path is not exercised.","Verify with a startup assertion: check settings().docling.langs is non-empty before starting ingestion workers."],"exampleFix":"# settings.yaml — before\n# docling:\n#   api_base: http://localhost:5001\n\n# after\n# docling:\n#   api_base: http://localhost:5001\n#   langs: [en]","handlingStrategy":"validation","validationCode":"from private_gpt.settings.settings import settings\n\ndef validate_ocr_settings() -> None:\n    d = settings().docling\n    if d.use_ocr and not d.langs:\n        raise SystemExit(\"docling.langs must be set when docling.use_ocr is true\")\n\nvalidate_ocr_settings()","typeGuard":null,"tryCatchPattern":"try:\n    langs = get_ocr_langs()\nexcept ValueError as e:\n    if \"No OCR languages\" in str(e):\n        langs = [\"en\"]  # only if a default is acceptable for your deployment\n    else:\n        raise","preventionTips":["Treat docling.langs as a required key whenever use_ocr is true; assert it at startup.","Keep the full docling block (langs included) in your settings template so custom configs inherit it."],"tags":["docling","ocr","configuration","validation"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}