chroma-core/chroma · error · ValueError
All input documents must be strings
Error message
All input documents must be strings
What it means
GoogleGeminiEmbeddingFunction.__call__ verifies every element of the input is a str. Non-string entries (ints, floats, None, bytes, dicts) are rejected because this embedding function is text-only: the Gemini text-embedding models have no defined behavior for other payloads, and silently coercing them could corrupt embeddings.
Source
Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:94
),
)
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,
)
except Exception as e:
raise ValueError(f"Failed to generate embeddings: {str(e)}") from e
# Validate response structureView on GitHub (pinned to aecdd12c8a)
Solutions
- Sanitize None/missing values before embedding: [d for d in docs if isinstance(d, str)] or fill defaults
- Coerce only when lossless and intended: [str(d) for d in docs]
- For images use an embedding function that supports multimodal input instead of this one
Example fix
# before vecs = ef(["doc one", None, 42]) # ValueError: All input documents must be strings # after docs = [d for d in ["doc one", None, 42] if isinstance(d, str)] vecs = ef(docs)
Defensive patterns
Strategy: type-guard
Validate before calling
docs = [d for d in docs if isinstance(d, str)] assert docs, "no string documents left after filtering" vecs = ef(docs)
Type guard
from typing import Any, TypeGuard
def is_all_strings(docs: Any) -> TypeGuard[list[str]]:
return isinstance(docs, (list, tuple)) and all(isinstance(d, str) for d in docs) Prevention
- Sanitize DataFrame columns: df['text'] = df['text'].fillna('') or drop NA rows before .tolist()
- Validate JSON records for null/numeric content fields upstream
- Never feed image bytes to a text-only embedding function; use a multimodal EF
When it happens
Trigger: Passing a list like ['doc one', 42]; None entries where source data had missing fields; image bytes (e.g. PIL/PNG data) intended for a multimodal model; JSON rows where a 'content' field is null or a nested object; mixed id/text columns accidentally zipped together.
Common situations: DataFrame column containing NaN/None passed after .tolist(); upstream JSON with null content fields not sanitized; attempting multimodal (image+text) retrieval with a text-only embedding function.
Related errors
- Input must be a list or tuple of documents
- Input must be a list of text documents (str) or a list of im
- Input documents cannot be empty
- Google Generative AI only supports text documents, not image
- Knn key must be a string or Key instance
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/cb5f5ae727a99649.
Report an issue: GitHub.