{"record":{"id":"e76b306c66e1580a","repo":"zylon-ai/private-gpt","slug":"failed-to-convert-file-info-file-data-to-target","errorCode":null,"errorMessage":"Failed to convert {file_info.file_data} to {target_extension}: {e}","messagePattern":"Failed to convert (.+?) to (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":500,"severity":"error","filePath":"private_gpt/components/ingest/utils.py","lineNumber":449,"sourceCode":"        subprocess.run(\n            [\n                \"soffice\",\n                \"--headless\",\n                \"--convert-to\",\n                target_extension.lstrip(\".\"),\n                \"--outdir\",\n                str(output_path.parent),\n                str(file_info.file_data),\n            ],\n            check=True,\n        )\n    except FileNotFoundError as e:\n        raise ImportError(\n            \"LibreOffice is required for file conversion. Please install LibreOffice.\"\n        ) from e\n    except subprocess.CalledProcessError as e:\n        if raise_in_exception:\n            raise RuntimeError(\n                f\"Failed to convert {file_info.file_data} to {target_extension}: {e}\"\n            ) from e\n        return file_info.file_data  # Return the original file on failure\n    return output_path\n\n\ndef 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)","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/ingest/utils.py#L431-L467","documentation":"RuntimeError raised by convert_file_with_libreoffice when the soffice subprocess exits non-zero (CalledProcessError) and raise_in_exception is true. The message includes the source file, target extension, and the subprocess error output. When raise_in_exception is false the original path is returned instead.","triggerScenarios":"Converting a corrupt or password-protected Office document with LibreOffice in strict mode: soffice runs but fails (exit code != 0), e.g. malformed .doc, encrypted file, or unsupported conversion target.","commonSituations":"Password-protected legacy Office uploads; partially transferred/corrupt files; LibreOffice profile lock contention under concurrent conversions in the same container.","solutions":["Try opening the file locally with LibreOffice to reproduce the conversion failure.","Remove password protection or repair/re-save the document.","Clear the LibreOffice user profile lock (-env:UserInstallation=file:///tmp/lo_profile) when running parallel conversions.","If partial failure is acceptable, call with raise_in_exception=False so the original file is returned for the fallback reader path."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    converted = convert_unsupported_file(file_info, raise_in_exception=True)\nexcept RuntimeError as e:\n    logger.warning('strict conversion failed (%s); retrying lenient', e)\n    converted = convert_unsupported_file(file_info, raise_in_exception=False)  # returns original on failure","preventionTips":["Use strict mode only when you can act on failure; lenient mode returns the original file for the fallback reader.","Smoke-test conversion of each distinct Office format users upload after image rebuilds."],"tags":["ingestion","libreoffice","conversion","corrupt-file"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}