zylon-ai/private-gpt · error · RuntimeError
Conversion failed: {e}
Error message
Conversion failed: {e} What it means
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.
Source
Thrown at private_gpt/components/ingest/utils.py:474
def convert_file(
file_info: FileInfo,
conversion_func: Callable[[FileInfo, str, bool], Path],
target_extension: str,
raise_in_exception: bool = False,
) -> FileInfo:
try:
converted_path = conversion_func(
file_info, target_extension, raise_in_exception
)
new_file_name = (
file_info.file_name.replace(file_info.extension, converted_path.suffix)
if file_info.file_name and file_info.extension
else None
)
return get_file_info(converted_path, file_name=new_file_name)
except Exception as e:
if raise_in_exception:
raise RuntimeError(f"Conversion failed: {e}") from e
return file_info # Return the original FileInfo on failure
def convert_unsupported_file(
file_info: FileInfo, raise_in_exception: bool = False
) -> FileInfo:
extensions_map = {
".xls": (".xlsx", convert_file_with_libreoffice),
".doc": (".docx", convert_file_with_libreoffice),
".ppt": (".pptx", convert_file_with_libreoffice),
}
if file_info.extension not in extensions_map:
return file_info # Return original FileInfo if no conversion is available
target_extension, conversion_func = extensions_map[file_info.extension]
return convert_file(
file_info, conversion_func, target_extension, raise_in_exception
)View on GitHub (pinned to 4a030776a3)
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.
Defensive patterns
Strategy: fallback
Try / catch
try:
converted = convert_file(file_info, convert_file_with_libreoffice, '.pdf', raise_in_exception=True)
except RuntimeError as e:
logger.warning('conversion failed: %s (cause=%s)', e, e.__cause__)
converted = file_info # proceed with original for fallback reader Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Deployments enabling strict conversion for data quality; corrupted uploads; missing LibreOffice dependency surfacing through this wrapper.
Related errors
- INVALID_REQUEST_ERROR
- Failed to convert {file_info.file_data} to {target_extension
- Invalid system item in list (dict): {item}
- Invalid system item in list: {item}
- Invalid system specification: {system}
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/91ae59cbaa0d8447.
Report an issue: GitHub.