chroma-core/chroma · error · ValueError
Malformed embedding response: missing 'values'
Error message
Malformed embedding response: missing 'values'
What it means
GoogleGeminiEmbeddingFunction iterates response.embeddings and requires each ContentEmbedding entry to expose a 'values' attribute; a missing 'values' means the API returned a structurally invalid embedding and the function aborts rather than emitting a corrupt vector. Like the empty-embeddings check, this guards against SDK shape drift and backend anomalies.
Source
Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:119
)
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 structure
if not hasattr(response, "embeddings") or not response.embeddings:
raise ValueError("No embeddings returned from the API")
embeddings_list = []
for ce in response.embeddings:
if not hasattr(ce, "values"):
raise ValueError("Malformed embedding response: missing 'values'")
embeddings_list.append(np.array(ce.values, dtype=np.float32))
return cast(Embeddings, embeddings_list)
@staticmethod
def name() -> str:
return "google_gemini"
def default_space(self) -> Space:
return "cosine"
def supported_spaces(self) -> List[Space]:
return ["cosine", "l2", "ip"]
@staticmethod
def build_from_config(config: Dict[str, Any]) -> "EmbeddingFunction[Documents]":
model_name = config.get("model_name")
task_type = config.get("task_type")View on GitHub (pinned to aecdd12c8a)
Solutions
- Pin google-genai to the version range your chromadb release was tested with
- Fix test mocks so each returned embedding has a values attribute
- Retry once for transient anomalies; capture the raw response for a bug report if persistent
Defensive patterns
Strategy: try-catch
Try / catch
try:
vecs = ef(docs)
except ValueError as e:
if "missing 'values'" in str(e):
# malformed ContentEmbedding: usually SDK version drift - pin/rollback google-genai
import google.genai
raise RuntimeError(
f"Malformed Gemini response with google-genai {google.genai.__version__}; "
"pin a compatible version"
) from e
raise Prevention
- Pin google-genai in requirements and upgrade chromadb+google-genai together
- In tests, mock each embedding entry with a values attribute
- Retry once before escalating - transient anomalies occur
When it happens
Trigger: A google-genai version where the per-embedding type renamed or made 'values' optional; a response containing embedding entries with unset values; incomplete test mocks of embed_content.
Common situations: Version mismatch between google-genai and chromadb after an upgrade; mocked clients in unit tests; unusual API edge responses.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- No embeddings returned from the API
- The google-genai python package is not installed. Please ins
- The {self.api_key_env_var} environment variable must be set
- Failed to generate embeddings: {str(e)}
- Unknown error
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/2c4a8c1307767f94.
Report an issue: GitHub.