{"record":{"id":"b8b97a890c80cbd6","repo":"chroma-core/chroma","slug":"the-model-name-is-required","errorCode":null,"errorMessage":"The model name is required.","messagePattern":"The model name is required\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/google_embedding_function.py","lineNumber":145,"sourceCode":"\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\")\n        dimension = config.get(\"dimension\")\n        api_key_env_var = config.get(\"api_key_env_var\", \"GEMINI_API_KEY\")\n        vertexai = config.get(\"vertexai\")\n        project = config.get(\"project\")\n        location = config.get(\"location\")\n\n        if model_name is None:\n            raise ValueError(\"The model name is required.\")\n\n        return GoogleGeminiEmbeddingFunction(\n            model_name=model_name,\n            task_type=task_type,\n            dimension=dimension,\n            api_key_env_var=api_key_env_var,\n            vertexai=vertexai,\n            project=project,\n            location=location,\n        )\n\n    def get_config(self) -> Dict[str, Any]:\n        config: Dict[str, Any] = {\n            \"model_name\": self.model_name,\n            \"api_key_env_var\": self.api_key_env_var,\n            \"vertexai\": self.vertexai,\n            \"project\": self.project,\n            \"location\": self.location,","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/google_embedding_function.py#L127-L163","documentation":"GoogleGeminiEmbeddingFunction.build_from_config requires the persisted config dict to contain 'model_name'; it is the only required key (task_type, dimension, etc. all default). It returns None-safe gets for everything else, so a config dict lacking model_name cannot identify which Gemini model to instantiate and the builder refuses.","triggerScenarios":"Calling GoogleGeminiEmbeddingFunction.build_from_config({}) or any dict without a 'model_name' key; hand-written or migrated config dicts where the key was dropped or renamed (e.g. 'model' instead of 'model_name'); corrupted persisted collection metadata being replayed.","commonSituations":"Manually crafting the config payload passed to get_embedding_function; migrating configs between chromadb versions; tests that build partial configs; editing stored JSON configs by hand.","solutions":["Include 'model_name' in the config, e.g. {'model_name': 'gemini-embedding-001', ...}","Emit configs from a live instance via ef.get_config() instead of writing them by hand - it always includes model_name","Validate the dict against the 'google_gemini' schema (GoogleGeminiEmbeddingFunction.validate_config) before building"],"exampleFix":"# before\nfrom chromadb.utils.embedding_functions import GoogleGeminiEmbeddingFunction\nef = GoogleGeminiEmbeddingFunction.build_from_config({\"task_type\": \"RETRIEVAL_DOCUMENT\"})  # ValueError\n\n# after\nef = GoogleGeminiEmbeddingFunction.build_from_config({\n    \"model_name\": \"gemini-embedding-001\",\n    \"task_type\": \"RETRIEVAL_DOCUMENT\",\n})","handlingStrategy":"validation","validationCode":"config = {\"model_name\": \"gemini-embedding-001\", \"task_type\": \"RETRIEVAL_DOCUMENT\"}\nassert config.get(\"model_name\"), \"model_name is required in google_gemini config\"\nef = GoogleGeminiEmbeddingFunction.build_from_config(config)","typeGuard":"from typing import Any, TypeGuard\n\ndef has_model_name(cfg: Any) -> TypeGuard[dict]:\n    return isinstance(cfg, dict) and isinstance(cfg.get(\"model_name\"), str) and bool(cfg[\"model_name\"])","tryCatchPattern":null,"preventionTips":["Generate configs with ef.get_config() from a live instance instead of hand-writing them","Run GoogleGeminiEmbeddingFunction.validate_config(config) before build_from_config","Add schema validation for persisted configs in migration scripts"],"tags":["config","build-from-config","gemini","chroma"],"backgroundTag":"missing-required-config-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}