zylon-ai/private-gpt · error · RuntimeError
Failed to extract file info
Error message
Failed to extract file info
What it means
RuntimeError from IngestionHelper.validate_file_info when the file_info argument is falsy — None, an empty object, or anything that fails the truthiness check. It is the first statement of a static method, so it fires before any size/extension validation and signals that upstream extraction (metadata probing of the uploaded file) never produced a FileInfo.
Source
Thrown at private_gpt/components/ingest/ingest_helper.py:21
from llama_index.core.schema import BaseNode
from private_gpt.components.ingest.metadata_helper import MetadataHelper
from private_gpt.components.ingest.progress.errors import IngestionValidationErrors
from private_gpt.components.ingest.utils import FileInfo, should_ignore_mime_mismatch
from private_gpt.settings.settings import settings
from private_gpt.utils.mime import is_magic_available
logger = logging.getLogger(__name__)
class IngestionHelper:
@staticmethod
def validate_file_info(
file_info: FileInfo,
) -> tuple[list[str], list[str]]:
if not file_info:
raise RuntimeError("Failed to extract file info")
errors = []
warnings = []
# Check if the file info has size
if file_info.file_size is None or file_info.file_size <= 0:
errors.append(IngestionValidationErrors.INVALID_FILE_SIZE)
# Check if the file info has extension
if not file_info.extension:
errors.append(IngestionValidationErrors.UNKNOWN_FILE_EXTENSION)
if is_magic_available() and not file_info.actual_mime_type:
errors.append(IngestionValidationErrors.UNKNOWN_FILE_EXTENSION)
if (
file_info.guest_mime_type
and file_info.actual_mime_typeView on GitHub (pinned to 4a030776a3)
Solutions
- Fix the upstream step that produces FileInfo so it never returns None (raise on extraction failure instead)
- Check the upload actually contains a readable, non-empty file before validation
- Pass a fully populated FileInfo: file_size > 0 and a non-empty extension, or validation will continue flagging errors
- Add a guard where FileInfo is built: if extraction fails, surface that error rather than forwarding None
Example fix
# before
file_info = extract_file_info(maybe_missing_upload) # returns None
errors, warnings = IngestionHelper.validate_file_info(file_info) # RuntimeError
# after
file_info = extract_file_info(upload)
if file_info is None:
raise ValueError('could not read upload metadata')
errors, warnings = IngestionHelper.validate_file_info(file_info) Defensive patterns
Strategy: validation
Validate before calling
if file_info is None or not file_info:
raise ValueError('file info missing: file metadata extraction failed or upload empty') Type guard
def has_file_info(fi) -> TypeGuard[FileInfo]:
return bool(fi) Try / catch
try:
errors, warnings = IngestionHelper.validate_file_info(file_info)
except RuntimeError as e:
if 'Failed to extract file info' in str(e):
return error_response(400, 'could not read file metadata; re-upload the file')
raise Prevention
- Never let the FileInfo extraction step return None silently — raise there instead
- Check the multipart upload contains a readable, non-empty file before processing
- Initialize FileInfo variables to a sentinel and assert on it before validation
When it happens
Trigger: Calling IngestionHelper.validate_file_info(file_info) with file_info=None or an empty FileInfo, e.g. when the file-metadata extraction step upstream returned nothing for a missing, unreadable, or zero-byte upload.
Common situations: Upload endpoints where the file metadata probe silently swallows exceptions and returns None; temp file deleted before validation; multipart form missing the file field; code paths that construct FileInfo only on success and pass an uninitialized variable otherwise.
Related errors
- File input requires valid base64 encoded content
- Invalid system specification (dict): {system}
- Invalid system item in list (dict): {item}
- 'oneOf' must be an array of schemas
- 'anyOf' must be an array of schemas
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/18bb8081689835f9.
Report an issue: GitHub.