{"record":{"id":"91ae59cbaa0d8447","repo":"zylon-ai/private-gpt","slug":"conversion-failed-e","errorCode":null,"errorMessage":"Conversion failed: {e}","messagePattern":"Conversion failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":500,"severity":"error","filePath":"private_gpt/components/ingest/utils.py","lineNumber":474,"sourceCode":"def convert_file(\n    file_info: FileInfo,\n    conversion_func: Callable[[FileInfo, str, bool], Path],\n    target_extension: str,\n    raise_in_exception: bool = False,\n) -> FileInfo:\n    try:\n        converted_path = conversion_func(\n            file_info, target_extension, raise_in_exception\n        )\n        new_file_name = (\n            file_info.file_name.replace(file_info.extension, converted_path.suffix)\n            if file_info.file_name and file_info.extension\n            else None\n        )\n        return get_file_info(converted_path, file_name=new_file_name)\n    except Exception as e:\n        if raise_in_exception:\n            raise RuntimeError(f\"Conversion failed: {e}\") from e\n        return file_info  # Return the original FileInfo on failure\n\n\ndef convert_unsupported_file(\n    file_info: FileInfo, raise_in_exception: bool = False\n) -> FileInfo:\n    extensions_map = {\n        \".xls\": (\".xlsx\", convert_file_with_libreoffice),\n        \".doc\": (\".docx\", convert_file_with_libreoffice),\n        \".ppt\": (\".pptx\", convert_file_with_libreoffice),\n    }\n    if file_info.extension not in extensions_map:\n        return file_info  # Return original FileInfo if no conversion is available\n\n    target_extension, conversion_func = extensions_map[file_info.extension]\n    return convert_file(\n        file_info, conversion_func, target_extension, raise_in_exception\n    )","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/ingest/utils.py#L456-L492","documentation":"RuntimeError raised by convert_file when the conversion_func throws and raise_in_exception is true; the original exception is chained. It wraps any converter failure (LibreOffice missing/failed, output file unreadable) behind a uniform 'Conversion failed' message. With raise_in_exception false, the original FileInfo is returned unchanged.","triggerScenarios":"Calling convert_file / convert_unsupported_file / convert_unsupported_file_as_fallback with a document whose conversion raises — e.g. soffice not installed (ImportError) or exiting non-zero — while strict mode is enabled.","commonSituations":"Deployments enabling strict conversion for data quality; corrupted uploads; missing LibreOffice dependency surfacing through this wrapper.","solutions":["Look at the chained cause (__cause__) to find the real failure — ImportError means missing soffice, CalledProcessError means soffice crashed on this file.","Install/fix LibreOffice or repair the source document accordingly.","Only enable raise_in_exception when callers can handle conversion failure; otherwise the graceful fallback returns the original FileInfo.","Validate the file opens in LibreOffice before ingest for exotic documents."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    converted = convert_file(file_info, convert_file_with_libreoffice, '.pdf', raise_in_exception=True)\nexcept RuntimeError as e:\n    logger.warning('conversion failed: %s (cause=%s)', e, e.__cause__)\n    converted = file_info  # proceed with original for fallback reader","preventionTips":["Always log e.__cause__ — the wrapper hides whether it was missing soffice vs a corrupt file.","Prefer the non-raising mode in user-facing ingest paths so one bad file does not fail the batch."],"tags":["ingestion","conversion","libreoffice","wrapper"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}