{"record":{"id":"2c4a8c1307767f94","repo":"chroma-core/chroma","slug":"malformed-embedding-response-missing-values","errorCode":null,"errorMessage":"Malformed embedding response: missing 'values'","messagePattern":"Malformed embedding response: missing 'values'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/google_embedding_function.py","lineNumber":119,"sourceCode":"        )\n\n        try:\n            response = self.client.models.embed_content(\n                model=self.model_name,\n                contents=input,\n                config=config,\n            )\n        except Exception as e:\n            raise ValueError(f\"Failed to generate embeddings: {str(e)}\") from e\n\n        # Validate response structure\n        if not hasattr(response, \"embeddings\") or not response.embeddings:\n            raise ValueError(\"No embeddings returned from the API\")\n\n        embeddings_list = []\n        for ce in response.embeddings:\n            if not hasattr(ce, \"values\"):\n                raise ValueError(\"Malformed embedding response: missing 'values'\")\n            embeddings_list.append(np.array(ce.values, dtype=np.float32))\n\n        return cast(Embeddings, embeddings_list)\n\n    @staticmethod\n    def name() -> str:\n        return \"google_gemini\"\n\n    def default_space(self) -> Space:\n        return \"cosine\"\n\n    def supported_spaces(self) -> List[Space]:\n        return [\"cosine\", \"l2\", \"ip\"]\n\n    @staticmethod\n    def build_from_config(config: Dict[str, Any]) -> \"EmbeddingFunction[Documents]\":\n        model_name = config.get(\"model_name\")\n        task_type = config.get(\"task_type\")","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/google_embedding_function.py#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"Version mismatch between google-genai and chromadb after an upgrade; mocked clients in unit tests; unusual API edge responses.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    vecs = ef(docs)\nexcept ValueError as e:\n    if \"missing 'values'\" in str(e):\n        # malformed ContentEmbedding: usually SDK version drift - pin/rollback google-genai\n        import google.genai\n        raise RuntimeError(\n            f\"Malformed Gemini response with google-genai {google.genai.__version__}; \"\n            \"pin a compatible version\"\n        ) from e\n    raise","preventionTips":["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"],"tags":["gemini","api-response","google-genai","chroma"],"backgroundTag":"malformed-api-response","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}