BerriAI/litellm · error · RuntimeError
Failed to import file into RAG corpus: {e}
Error message
Failed to import file into RAG corpus: {e} What it means
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.
Source
Thrown at litellm/llms/vertex_ai/rag_engine/ingestion.py:297
Tuple of (corpus_id, gcs_uri)
"""
if not file_content or not filename:
verbose_logger.warning("No file content or filename provided for Vertex AI ingestion")
return _get_str_or_none(self.corpus_id), None
# Step 1: Upload file to GCS
gcs_uri: Final = await self._upload_file_to_gcs(
file_content=file_content,
filename=filename,
content_type=content_type or "application/octet-stream",
)
# Step 2: Import file into RAG corpus
try:
await self._import_file_to_corpus_via_sdk(gcs_uri=gcs_uri)
except Exception as e:
verbose_logger.error("Failed to import file into RAG corpus: %s", e)
raise RuntimeError(f"Failed to import file into RAG corpus: {e}") from e
return str(self.corpus_id), gcs_uri
View on GitHub (pinned to 77b7c6c40c)
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
Defensive patterns
Strategy: try-catch
Validate before calling
def corpus_name_ok(project: str, location: str, corpus_id: str) -> bool:
return all([project, location, corpus_id]) and location == EXPECTED_CORPUS_LOCATION
assert corpus_name_ok(project, location, corpus_id), 'corpus name parts missing or location mismatch' Try / catch
try:
... # run the Vertex RAG ingestion (upload + import)
except RuntimeError as e:
# e.__cause__ holds the original google-cloud SDK exception
log.error('rag import failed: %s', e.__cause__ or e)
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- gcs_bucket is required for Vertex AI RAG ingestion. Set via
- vector_store_id (corpus ID) is required for Vertex AI RAG in
- vertex_project is required for Vertex AI RAG ingestion. Set
- vertexai.rag module not found. Vertex AI RAG requires google
- Source video has neither gcsUri nor bytesBase64Encoded. Cann
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/79799459058b835c.
Report an issue: GitHub.