zylon-ai/private-gpt · error · RuntimeError
Failed to convert {file_info.file_data} to {target_extension
Error message
Failed to convert {file_info.file_data} to {target_extension}: {e} What it means
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.
Source
Thrown at private_gpt/components/ingest/utils.py:449
subprocess.run(
[
"soffice",
"--headless",
"--convert-to",
target_extension.lstrip("."),
"--outdir",
str(output_path.parent),
str(file_info.file_data),
],
check=True,
)
except FileNotFoundError as e:
raise ImportError(
"LibreOffice is required for file conversion. Please install LibreOffice."
) from e
except subprocess.CalledProcessError as e:
if raise_in_exception:
raise RuntimeError(
f"Failed to convert {file_info.file_data} to {target_extension}: {e}"
) from e
return file_info.file_data # Return the original file on failure
return output_path
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)View on GitHub (pinned to 4a030776a3)
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.
Defensive patterns
Strategy: fallback
Try / catch
try:
converted = convert_unsupported_file(file_info, raise_in_exception=True)
except RuntimeError as e:
logger.warning('strict conversion failed (%s); retrying lenient', e)
converted = convert_unsupported_file(file_info, raise_in_exception=False) # returns original on failure Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Password-protected legacy Office uploads; partially transferred/corrupt files; LibreOffice profile lock contention under concurrent conversions in the same container.
Related errors
- INVALID_REQUEST_ERROR
- Conversion failed: {e}
- Failed to load file '{file_info.file_name}' with readers: {a
- Invalid system item in list (dict): {item}
- Invalid system item in list: {item}
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/e76b306c66e1580a.
Report an issue: GitHub.