{"record":{"id":"9d0dfe2f5073d652","repo":"BerriAI/litellm","slug":"failed-to-upload-file-response-text","errorCode":null,"errorMessage":"Failed to upload file: {response.text}","messagePattern":"Failed to upload file: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/rag/ingestion/gemini_ingestion.py","lineNumber":319,"sourceCode":"            \"X-Goog-Upload-Command\": \"upload, finalize\",\n        }\n\n        verbose_logger.debug(\"Uploading file content (%s bytes)\", len(file_content))\n\n        client: Final = get_async_httpx_client(\n            llm_provider=httpxSpecialProvider.RAG,\n            params={\"timeout\": 300.0},  # Longer timeout for large files\n        )\n        response: Final = await client.put(\n            upload_url,\n            content=file_content,\n            headers=headers,\n        )\n\n        if response.status_code not in [200, 201]:\n            error_msg: Final = f\"Failed to upload file: {response.text}\"\n            verbose_logger.error(error_msg)\n            raise Exception(error_msg)\n\n        # Parse response to get file/document ID\n        try:\n            response_data: Final = response.json()\n            # The response should contain the document name or file reference\n            file_id: Final = response_data.get(\"name\", \"\") or response_data.get(\"file\", {}).get(\"name\", \"\")\n            verbose_logger.debug(\"Upload complete. File ID: %s\", file_id)\n            return file_id\n        except Exception as e:\n            verbose_logger.warning(\"Could not parse upload response: %s\", e)\n            # Return a placeholder if we can't get the ID\n            return \"uploaded\"\n","sourceCodeStart":301,"sourceCodeEnd":332,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/rag/ingestion/gemini_ingestion.py#L301-L332","documentation":"The final PUT to the resumable upload URL returned a non-200/201 status, so the file content was not (fully) accepted by Gemini. The response body '{response.text}' gives the reason; a fresh upload session is required on retry since resumable URLs are single-use.","triggerScenarios":"Thrown at litellm/rag/ingestion/gemini_ingestion.py:319 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the response text for the upload error and retry with a valid file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}