{"record":{"id":"101f2bed4c39f505","repo":"crewAIInc/crewAI","slug":"video-processing-failed-for-file-filename","errorCode":null,"errorMessage":"Video processing failed for {file.filename}","messagePattern":"Video processing failed for (.+?)","errorType":"exception","errorClass":"PermanentUploadError","httpStatus":null,"severity":"error","filePath":"lib/crewai-files/src/crewai_files/uploaders/gemini.py","lineNumber":184,"sourceCode":"                content = file.read()\n                file_data = io.BytesIO(content)\n                file_data.name = file.filename\n\n                logger.info(\n                    f\"Uploading file '{file.filename}' to Gemini ({len(content)} bytes)\"\n                )\n\n                uploaded_file = client.files.upload(\n                    file=file_data,\n                    config={\n                        \"display_name\": display_name,\n                        \"mime_type\": file.content_type,\n                    },\n                )\n\n            if file.content_type.startswith(\"video/\"):\n                if not self.wait_for_processing(uploaded_file.name):\n                    raise PermanentUploadError(\n                        f\"Video processing failed for {file.filename}\",\n                        file_name=file.filename,\n                    )\n\n            expires_at = datetime.now(timezone.utc) + GEMINI_FILE_TTL\n\n            logger.info(\n                f\"Uploaded to Gemini: {uploaded_file.name} (URI: {uploaded_file.uri})\"\n            )\n\n            return UploadResult(\n                file_id=uploaded_file.name,\n                file_uri=uploaded_file.uri,\n                content_type=file.content_type,\n                expires_at=expires_at,\n                provider=self.provider_name,\n            )\n        except ImportError:","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-files/src/crewai_files/uploaders/gemini.py#L166-L202","documentation":"PermanentUploadError raised by the sync Gemini upload path when the uploaded file's content_type starts with video/ and wait_for_processing(file_id) returns False, i.e. Gemini's Files API did not finish (or failed) processing the video within the uploader's wait budget. It is a subclass of UploadError and PermanentFileError, signaling retrying the same upload will not help.","triggerScenarios":"Uploading a video/* file (mp4, webm, etc.) where Gemini's server-side processing stays in the 'processing' state past the polling timeout, or transitions to FAILED, so wait_for_processing returns False.","commonSituations":"Large or long videos that exceed the default polling window; unusual codecs that Gemini cannot process; transient Google-side processing failures; uploading many videos in parallel slowing processing.","solutions":["Retry once with a smaller/shorter or re-encoded (H.264 mp4) video; codec/size issues are the usual cause.","Check the file state via client.files.get(file_id) to distinguish still-processing from FAILED before retrying.","Raise the uploader's wait timeout/polling budget if videos are legitimately large and processing is just slow.","Treat PermanentUploadError as non-retryable in generic retry logic and surface it to the user for re-encoding."],"exampleFix":"# before\nresult = gemini_uploader.upload(video_file)  # PermanentUploadError on slow processing\n\n# after\ntry:\n    result = gemini_uploader.upload(video_file)\nexcept PermanentUploadError:\n    # re-encode or split the video, then retry once\n    result = gemini_uploader.upload(reencode_h264(video_file))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from crewai_files.uploaders.exceptions import PermanentUploadError  # or processing.exceptions\ntry:\n    result = gemini_uploader.upload(video_file)\nexcept PermanentUploadError as e:\n    # non-retryable: re-encode/downscale the video, then retry once manually\n    logger.error(\"Gemini could not process %s\", e)\n    raise","preventionTips":["Pre-validate videos: prefer H.264/mp4, reasonable size and duration.","Give the uploader a generous processing-wait budget for large videos.","Never blind-retry PermanentUploadError in generic backoff loops."],"tags":["gemini","video","processing-timeout","file-upload","permanent"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}