zylon-ai/private-gpt · error · InvalidFileError

zpgt.ingest.invalid_file_size.error

zpgt.ingest.invalid_file_size.error

Error message

zpgt.ingest.invalid_file_size.error

What it means

InvalidFileError raised during _validate_file when IngestionHelper.validate_file_info returns a non-empty errors list — most commonly file-size validation failures (zpgt.ingest.invalid_file_size.error). The validation errors list is included in the exception so callers can see every failed rule.

Source

Thrown at private_gpt/components/ingest/parse_component.py:185

    def _get_file_info(
        self,
        file_data: Path,
        file_metadata: dict[str, Any] | None,
        progress: NotifyProtocol | None = None,
    ) -> FileInfo:
        file_name = get_file_name(file_metadata) or file_data.name
        return get_file_info(file_data, file_name=file_name, progress=progress)

    def _validate_file(
        self,
        file_info: FileInfo,
        progress: NotifyProtocol,
    ) -> tuple[list[str], list[str]]:
        errors, warnings = IngestionHelper.validate_file_info(file_info)
        if errors:
            logger.info("Validation errors: %s", errors)
            raise InvalidFileError(errors=errors, warnings=warnings)
        if warnings:
            logger.info("Validation warnings: %s", warnings)
            progress(percentage=100, warnings=warnings)
        return errors, warnings

    def _load_data(
        self,
        file_info: FileInfo,
        file_metadata: dict[str, Any] | None,
        notification: NotifyProtocol | None = None,
        warnings: list[str] | None = None,
        reader_name: str | None = None,
    ) -> list[BaseNode]:
        return asyncio.run(
            self._aload_data(
                file_info=file_info,
                file_metadata=file_metadata,
                notification=notification,

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Read the errors list on the raised InvalidFileError — it names the exact rule(s) that failed (e.g. file too large).
  2. Compress or split the document to satisfy the configured size limit, or raise the limit in the ingestion config.
  3. For 0-byte files, verify the upload actually transferred the bytes (check Content-Length, proxy limits like nginx client_max_body_size).
  4. Confirm the extension is in the allowed list before upload.
Defensive patterns

Strategy: validation

Validate before calling

size = os.path.getsize(path)
if size > settings.ingestion.max_file_size or size < settings.ingestion.min_file_size:
    raise ValueError(f'file size {size} outside allowed bounds')

Try / catch

try:
    file_info, errors, warnings = ingest.validate_file(path, metadata)
except InvalidFileError as e:
    return api_error(422, details=e.errors)  # list of failed validation rules

Prevention

When it happens

Trigger: Calling validate_file / ingest with a file whose size is outside the configured min/max bounds, or otherwise fails validate_file_info rules (bad extension, etc.). The error propagates before any parsing begins.

Common situations: Uploading a document larger than the configured maximum ingest size; uploading a 0-byte file below the minimum; changing size limits in config after files were staged; proxy body-size limits producing tiny truncated files.

Related errors


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