crewAIInc/crewAI · error · FileProcessingError
str(e)
Error message
str(e)
What it means
FileProcessor.process wraps unexpected (non-validation) exceptions: FileValidationError, FileTooLargeError and UnsupportedFileTypeError are re-raised as-is, but any other Exception is logged and, in STRICT mode, re-raised as FileProcessingError(str(e)) with file_name set and the original as __cause__. This surfaces corrupt files, unreadable bytes, or processing bugs as a uniform error type.
Source
Thrown at lib/crewai-files/src/crewai_files/processing/processor.py:155
if mode == FileHandling.WARN:
for error in errors:
logger.warning(error)
return file
if mode == FileHandling.AUTO:
return self._auto_process(file)
if mode == FileHandling.CHUNK:
return self._chunk_process(file)
return file
except (FileValidationError, FileTooLargeError, UnsupportedFileTypeError):
raise
except Exception as e:
logger.error(f"Error processing file '{file.filename}': {e}")
if mode == FileHandling.STRICT:
raise FileProcessingError(str(e), file_name=file.filename) from e
return file
def process_files(
self,
files: dict[str, FileInput],
) -> dict[str, FileInput]:
"""Process multiple files according to constraints.
Args:
files: Dictionary mapping names to file inputs.
Returns:
Dictionary mapping names to processed files. If a file is chunked,
multiple entries are created with indexed names.
"""
result: dict[str, FileInput] = {}
for name, file in files.items():View on GitHub (pinned to 754d7323be)
Solutions
- Inspect the message and the __cause__ (raise ... from e preserves it) to find the real underlying failure.
- Open the offending file with the same library (PIL.Image.open, pypdf.PdfReader) locally to reproduce.
- If files may be untrusted, wrap process() per-file so one bad file does not kill the batch, and skip/quarantine failures.
- Verify the file is fully downloaded/written before processing (check size, completeness).
Example fix
# before
try:
out = processor.process(file)
except FileProcessingError as e:
abort_whole_batch() # one corrupt file kills everything
# after
try:
out = processor.process(file)
except FileProcessingError as e:
logger.error("skipping %s: %s (cause: %r)", e.file_name, e, e.__cause__)
quarantined.append(file) # continue with remaining files Defensive patterns
Strategy: try-catch
Validate before calling
if file.read()[:4] == b"": # quick sanity: non-empty payload
logger.warning("%s appears empty; skipping", file.filename) Try / catch
from crewai_files.processing.exceptions import FileProcessingError
try:
out = processor.process(file)
except FileProcessingError as e:
if isinstance(e, FileValidationError):
raise # validation failures are deterministic
logger.error("processing failed for %s: %s (cause=%r)", e.file_name, e, e.__cause__)
quarantined.append(file) Prevention
- Always inspect __cause__ — the real failure is the wrapped exception.
- Process files individually so one corrupt file cannot abort a batch.
- Verify downloads/writes completed (size check) before processing.
When it happens
Trigger: Any non-validation exception during processing in STRICT mode: struct.error or OSError from Pillow opening a corrupt image, pypdf PdfReader failing on a malformed PDF, zero-byte reads, or truncated base64. The error message is str(e) of the underlying exception, so its text varies.
Common situations: User uploads a corrupt or truncated image/PDF; a partially-downloaded file; Pillow/pypdf version drift changing exception types; a bug in a custom transformer raising an arbitrary exception.
Related errors
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/63a3ab8e035b0e9a.
Report an issue: GitHub.