zylon-ai/private-gpt · error · ImportError

INVALID_REQUEST_ERROR

INVALID_REQUEST_ERROR

Error message

LibreOffice is required for file conversion. Please install LibreOffice.

What it means

ImportError raised by convert_file_with_libreoffice when subprocess.run(['soffice', ...]) raises FileNotFoundError — the LibreOffice executable is not installed or not on PATH. The message tells you explicitly to install LibreOffice; tagged INVALID_REQUEST_ERROR at the API layer.

Source

Thrown at private_gpt/components/ingest/utils.py:444

def convert_file_with_libreoffice(
    file_info: FileInfo, target_extension: str, raise_in_exception: bool = False
) -> Path:
    output_path = file_info.file_data.with_suffix(target_extension)
    try:
        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:

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Install LibreOffice in the environment running ingestion: 'apt-get install -y libreoffice' (Debian/Ubuntu) or add libreoffice to the Docker image.
  2. Verify with 'soffice --version' from the same shell/user the service runs as.
  3. If a full install is too heavy, install libreoffice-core + the specific format filters.
  4. Alternatively pre-convert .xls/.doc/.ppt files to modern formats upstream so LibreOffice is never needed.

Example fix

# Dockerfile
# before
FROM python:3.12-slim

# after
FROM python:3.12-slim
RUN apt-get update && apt-get install -y --no-install-recommends libreoffice && rm -rf /var/lib/apt/lists/*
Defensive patterns

Strategy: validation

Validate before calling

import shutil
if shutil.which('soffice') is None:
    raise RuntimeError('LibreOffice (soffice) not found on PATH; install it before ingesting legacy Office files')

Try / catch

try:
    converted = convert_unsupported_file(file_info)
except ImportError as e:
    if 'LibreOffice' in str(e):
        return api_error(503, 'Legacy format conversion unavailable: LibreOffice not installed')

Prevention

When it happens

Trigger: Ingesting a legacy Office file (.xls/.doc/.ppt) or any format routed through convert_unsupported_file / fallback conversion when 'soffice' is missing from PATH in the server/worker container.

Common situations: Slim Docker images without LibreOffice; CI environments; deploying to a host where LibreOffice was never installed; PATH not including /usr/bin in the service unit.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/89880fc740fb2c0d. Report an issue: GitHub.