{"record":{"id":"63a3ab8e035b0e9a","repo":"crewAIInc/crewAI","slug":"str-e","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"exception","errorClass":"FileProcessingError","httpStatus":null,"severity":"error","filePath":"lib/crewai-files/src/crewai_files/processing/processor.py","lineNumber":155,"sourceCode":"            if mode == FileHandling.WARN:\n                for error in errors:\n                    logger.warning(error)\n                return file\n\n            if mode == FileHandling.AUTO:\n                return self._auto_process(file)\n\n            if mode == FileHandling.CHUNK:\n                return self._chunk_process(file)\n\n            return file\n\n        except (FileValidationError, FileTooLargeError, UnsupportedFileTypeError):\n            raise\n        except Exception as e:\n            logger.error(f\"Error processing file '{file.filename}': {e}\")\n            if mode == FileHandling.STRICT:\n                raise FileProcessingError(str(e), file_name=file.filename) from e\n            return file\n\n    def process_files(\n        self,\n        files: dict[str, FileInput],\n    ) -> dict[str, FileInput]:\n        \"\"\"Process multiple files according to constraints.\n\n        Args:\n            files: Dictionary mapping names to file inputs.\n\n        Returns:\n            Dictionary mapping names to processed files. If a file is chunked,\n            multiple entries are created with indexed names.\n        \"\"\"\n        result: dict[str, FileInput] = {}\n\n        for name, file in files.items():","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-files/src/crewai_files/processing/processor.py#L137-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"# before\ntry:\n    out = processor.process(file)\nexcept FileProcessingError as e:\n    abort_whole_batch()  # one corrupt file kills everything\n\n# after\ntry:\n    out = processor.process(file)\nexcept FileProcessingError as e:\n    logger.error(\"skipping %s: %s (cause: %r)\", e.file_name, e, e.__cause__)\n    quarantined.append(file)  # continue with remaining files","handlingStrategy":"try-catch","validationCode":"if file.read()[:4] == b\"\":  # quick sanity: non-empty payload\n    logger.warning(\"%s appears empty; skipping\", file.filename)","typeGuard":null,"tryCatchPattern":"from crewai_files.processing.exceptions import FileProcessingError\n\ntry:\n    out = processor.process(file)\nexcept FileProcessingError as e:\n    if isinstance(e, FileValidationError):\n        raise  # validation failures are deterministic\n    logger.error(\"processing failed for %s: %s (cause=%r)\", e.file_name, e, e.__cause__)\n    quarantined.append(file)","preventionTips":["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."],"tags":["file-processing","wrapper-exception","strict-mode","corrupt-file"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}