{"record":{"id":"10f8b0d8abc2acd8","repo":"chroma-core/chroma","slug":"no-embeddings-returned-from-the-api","errorCode":null,"errorMessage":"No embeddings returned from the API","messagePattern":"No embeddings returned from the API","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/google_embedding_function.py","lineNumber":114,"sourceCode":"        from google.genai.types import EmbedContentConfig\n\n        config = EmbedContentConfig(\n            task_type=self.task_type,\n            output_dimensionality=self.dimension,\n        )\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\"]","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/google_embedding_function.py#L96-L132","documentation":"After a successful embed_content call, GoogleGeminiEmbeddingFunction validates the response shape: response must have a non-empty 'embeddings' attribute. An HTTP-200 response with no embeddings violates the API contract, so the function refuses to return an empty/partial result. This is almost always SDK-version drift or a backend anomaly rather than a user-input problem.","triggerScenarios":"A google-genai version whose response object lacks or empties the 'embeddings' field; a Gemini backend anomaly returning an empty embedding list; a mocked/stubbed client in tests that returns an object without .embeddings.","commonSituations":"Upgrading google-genai to a release with changed response types; test doubles that mimic the client incompletely; rare upstream incidents.","solutions":["Pin google-genai to a version known to work with your chromadb release (check chromadb's optional-dependency pins)","If it occurs in tests, make the mock return an object with embeddings=[...] where each item has .values","Retry once - transient backend anomalies can clear","Report with the raw response if it persists across pinned versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    vecs = ef(docs)\nexcept ValueError as e:\n    if \"No embeddings returned\" in str(e):\n        # response-shape anomaly (SDK drift/backend glitch): capture context, retry once\n        vecs = ef(docs)\n    else:\n        raise","preventionTips":["Pin google-genai to the version range tested with your chromadb release","Make test mocks return objects with non-empty embeddings=[...] entries","Log model_name and google-genai version alongside the failure for diagnosability"],"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"}