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

  1. Pin google-genai to the version range your chromadb release was tested with
  2. Fix test mocks so each returned embedding has a values attribute
  3. 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

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

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/2c4a8c1307767f94. Report an issue: GitHub.