chroma-core/chroma · error · ValueError
Input documents cannot be empty
Error message
Input documents cannot be empty
What it means
GoogleGeminiEmbeddingFunction.__call__ rejects empty input before contacting the API. The Gemini embed_content endpoint requires at least one content item, and embedding zero documents is meaningless, so a falsy input (empty list/tuple) raises immediately.
Source
Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:90
project=project,
location=location,
http_options=types.HttpOptions(
headers={"x-goog-api-client": f"chroma/{__version__}"}
),
)
def __call__(self, input: Documents) -> Embeddings:
"""
Generate embeddings for the given documents.
Args:
input: Documents to generate embeddings for.
Returns:
Embeddings for the documents.
"""
if not input:
raise ValueError("Input documents cannot be empty")
if not isinstance(input, (list, tuple)):
raise ValueError("Input must be a list or tuple of documents")
if not all(isinstance(doc, str) for doc in input):
raise ValueError("All input documents must be strings")
from google.genai.types import EmbedContentConfig
config = EmbedContentConfig(
task_type=self.task_type,
output_dimensionality=self.dimension,
)
try:
response = self.client.models.embed_content(
model=self.model_name,
contents=input,
config=config,
)View on GitHub (pinned to aecdd12c8a)
Solutions
- Short-circuit before embedding: if the batch is empty, skip the call or return []
- Fix chunking logic so it never yields an empty final chunk (e.g. range(0, n, size))
- Validate user-supplied query text is non-empty before calling collection.query
Example fix
# before ef = GoogleGeminiEmbeddingFunction() vecs = ef(batch) # crashes when batch == [] # after ef = GoogleGeminiEmbeddingFunction() vecs = ef(batch) if batch else []
Defensive patterns
Strategy: validation
Validate before calling
def safe_embed(ef, docs):
if not docs:
return [] # nothing to embed; skip the API entirely
return ef(docs) Type guard
from typing import Any
def is_nonempty_batch(docs: Any) -> bool:
return isinstance(docs, (list, tuple)) and len(docs) > 0 Prevention
- Guard batch loops: if not batch: continue
- Fix chunkers to never emit an empty final chunk (range(0, len(docs), size))
- Validate user query text is non-empty before calling collection.query
When it happens
Trigger: Calling ef([]) directly; passing an empty batch produced by chunking code whose last chunk is empty; query flows where the query_texts filter or user input produced zero items; collection.query with an empty documents/query_texts list reaching the embedding function.
Common situations: Batch ingestion loops that slice documents into fixed-size chunks and send a final empty remainder; upstream filters that legitimately return zero matches but are still passed to the embedding function; empty user search box submitted without validation.
Related errors
- Input must be a list or tuple of documents
- All input documents must be strings
- Invalid URL. Unrecognized protocol - {parsed.scheme}.
- Invalid URL. Seems that you are trying to pass URL as a host
- Record does not contain any non-None fields that can be embe
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/21d64dc70753a788.
Report an issue: GitHub.