{"record":{"id":"e4ff64e7b52b8c12","repo":"chroma-core/chroma","slug":"the-vertexai-cannot-be-changed-after-the-embedding","errorCode":null,"errorMessage":"The vertexai cannot be changed after the embedding function has been initialized.","messagePattern":"The vertexai cannot be changed after the embedding function has been initialized\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/google_embedding_function.py","lineNumber":183,"sourceCode":"        if self.task_type is not None:\n            config[\"task_type\"] = self.task_type\n        if self.dimension is not None:\n            config[\"dimension\"] = self.dimension\n        return config\n\n    def validate_config_update(\n        self, old_config: Dict[str, Any], new_config: Dict[str, Any]\n    ) -> None:\n        if \"model_name\" in new_config:\n            raise ValueError(\n                \"The model name cannot be changed after the embedding function has been initialized.\"\n            )\n        if \"dimension\" in new_config:\n            raise ValueError(\n                \"The dimension cannot be changed after the embedding function has been initialized.\"\n            )\n        if \"vertexai\" in new_config:\n            raise ValueError(\n                \"The vertexai cannot be changed after the embedding function has been initialized.\"\n            )\n        if \"project\" in new_config:\n            raise ValueError(\n                \"The project cannot be changed after the embedding function has been initialized.\"\n            )\n        if \"location\" in new_config:\n            raise ValueError(\n                \"The location cannot be changed after the embedding function has been initialized.\"\n            )\n\n    @staticmethod\n    def validate_config(config: Dict[str, Any]) -> None:\n        \"\"\"\n        Validate the configuration using the JSON schema.\n\n        Args:\n            config: Configuration to validate","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/google_embedding_function.py#L165-L201","documentation":"GoogleGeminiEmbeddingFunction.validate_config_update rejects update payloads containing a 'vertexai' key. Auth mode (API key vs Vertex AI ADC) is fixed at client construction; flipping it later would silently change credential resolution against an existing client, so the field is immutable by design.","triggerScenarios":"Trying to switch a collection's embedding function from Gemini API-key auth to vertexai=True (or vice versa) via modify/config update; passing a full get_config() dict (which always includes the vertexai key) as the new config.","commonSituations":"Promoting a prototype from AI Studio keys to production Vertex credentials and attempting an in-place swap; copy-pasting full configs as update payloads.","solutions":["Recreate the embedding function (and effectively the collection workflow) with the desired auth mode from the start","Drop the 'vertexai' key from update payloads that only intend to change mutable settings like api_key_env_var or task_type","Model auth changes as a migration: new collection, re-embed, repoint readers"],"exampleFix":"# before\nnew_config = {\"vertexai\": True, \"project\": \"my-proj\", \"location\": \"us-central1\"}\nef.validate_config_update(old, new_config)  # ValueError: vertexai immutable\n\n# after - only mutable keys in the update\nnew_config = {\"api_key_env_var\": \"GOOGLE_API_KEY\"}\nef.validate_config_update(old, new_config)","handlingStrategy":"validation","validationCode":"IMMUTABLE = {\"model_name\", \"dimension\", \"vertexai\", \"project\", \"location\"}\n\nupdate = {k: v for k, v in desired_config.items() if k not in IMMUTABLE}\nassert \"vertexai\" not in update\nef.validate_config_update(old_config, update)","typeGuard":"from typing import Any, TypeGuard\n\nMUTABLE_GEMINI_KEYS = {\"api_key_env_var\", \"task_type\"}\n\ndef is_mutable_update(cfg: Any) -> TypeGuard[dict]:\n    return isinstance(cfg, dict) and set(cfg) <= MUTABLE_GEMINI_KEYS","tryCatchPattern":null,"preventionTips":["Fix the auth mode (API key vs Vertex) per environment at deployment time","Keep get_config() output out of update payloads","Model auth-mode changes as a re-deployment, not a config edit"],"tags":["immutable-config","vertexai","gemini","chroma"],"backgroundTag":"immutable-config-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}