{"record":{"id":"79799459058b835c","repo":"BerriAI/litellm","slug":"failed-to-import-file-into-rag-corpus-e","errorCode":null,"errorMessage":"Failed to import file into RAG corpus: {e}","messagePattern":"Failed to import file into RAG corpus: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/rag_engine/ingestion.py","lineNumber":297,"sourceCode":"            Tuple of (corpus_id, gcs_uri)\n        \"\"\"\n        if not file_content or not filename:\n            verbose_logger.warning(\"No file content or filename provided for Vertex AI ingestion\")\n            return _get_str_or_none(self.corpus_id), None\n\n        # Step 1: Upload file to GCS\n        gcs_uri: Final = await self._upload_file_to_gcs(\n            file_content=file_content,\n            filename=filename,\n            content_type=content_type or \"application/octet-stream\",\n        )\n\n        # Step 2: Import file into RAG corpus\n        try:\n            await self._import_file_to_corpus_via_sdk(gcs_uri=gcs_uri)\n        except Exception as e:\n            verbose_logger.error(\"Failed to import file into RAG corpus: %s\", e)\n            raise RuntimeError(f\"Failed to import file into RAG corpus: {e}\") from e\n\n        return str(self.corpus_id), gcs_uri\n","sourceCodeStart":279,"sourceCodeEnd":300,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/rag_engine/ingestion.py#L279-L300","documentation":"RuntimeError raised when the SDK call that imports an already-uploaded GCS file into the RAG corpus raises any exception. The original exception is logged and chained with `raise ... from e`, and its text is embedded in the message - so the underlying google-cloud SDK error is the real signal. It fires only after the GCS upload step succeeded.","triggerScenarios":"Corpus resource name wrong or in another region (projects/{project}/locations/{location}/ragCorpora/{id} does not resolve); the Vertex AI / RAG API not enabled; the service account lacks aiplatform or RAG permissions; corpus quota limits hit.","commonSituations":"vertex_location mismatch between corpus and config; SA granted storage rights but not Vertex AI User; corpus deleted between job creation and import; document in a format the importer rejects.","solutions":["Read the SDK error text inside the message - it comes verbatim from google-cloud-aiplatform and names the real cause","Verify the corpus name: same project, same location, existing corpus ID","Enable the Vertex AI API in the project and grant the service account Vertex AI User (plus RAG permissions)","Note that the GCS upload already succeeded - focus on the corpus/API side, not the bucket"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def corpus_name_ok(project: str, location: str, corpus_id: str) -> bool:\n    return all([project, location, corpus_id]) and location == EXPECTED_CORPUS_LOCATION\n\nassert corpus_name_ok(project, location, corpus_id), 'corpus name parts missing or location mismatch'","typeGuard":null,"tryCatchPattern":"try:\n    ...  # run the Vertex RAG ingestion (upload + import)\nexcept RuntimeError as e:\n    # e.__cause__ holds the original google-cloud SDK exception\n    log.error('rag import failed: %s', e.__cause__ or e)\n    raise","preventionTips":["Pre-create the corpus and verify its location matches vertex_location","Grant the SA both Storage Object Creator (bucket) and Vertex AI User (project)","Dry-run imports with small files before bulk ingestion","Monitor import jobs; set import_timeout/wait_for_import deliberately"],"tags":["vertex-ai","rag","gcs","sdk-error","chained-exception"],"backgroundTag":"third-party-sdk-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}