{"record":{"id":"b092a6c5b09061fd","repo":"chroma-core/chroma","slug":"the-location-cannot-be-changed-after-the-embedding","errorCode":null,"errorMessage":"The location cannot be changed after the embedding function has been initialized.","messagePattern":"The location 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":191,"sourceCode":"    ) -> 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\n\n        Raises:\n            ValidationError: If the configuration does not match the schema\n        \"\"\"\n        validate_config_schema(config, \"google_gemini\")\n\n\n# Backward compatibility alias","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/google_embedding_function.py#L173-L209","documentation":"GoogleGeminiEmbeddingFunction.validate_config_update rejects update payloads containing a 'location' key. The Vertex AI region is fixed when genai.Client is constructed; changing regions after the fact would redirect requests to a different deployment with independently stored state, so it is validated as immutable.","triggerScenarios":"Attempting to change region (e.g. us-central1 to europe-west1) through a config update on an existing function; passing a full config dict from get_config() - which always includes location - as the update payload.","commonSituations":"Data-residency moves across regions; latency optimization attempts after initial deployment; full-config copy-paste used as an update.","solutions":["Create a new deployment/collection in the target region and re-embed","Strip 'location' (and the other immutable keys) from update payloads; only api_key_env_var and task_type are meant to change","Choose the region deliberately before first ingestion"],"exampleFix":"# before\nnew_config = {\"location\": \"europe-west1\", \"task_type\": \"RETRIEVAL_QUERY\"}\nef.validate_config_update(old, new_config)  # ValueError: location immutable\n\n# after\nnew_config = {\"task_type\": \"RETRIEVAL_QUERY\"}\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 \"location\" 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":["Choose the Vertex region before initial ingestion; region moves require re-embedding","Whitelist mutable keys in config-update code paths","Store region with other deployment constants, not in mutable config"],"tags":["immutable-config","gcp-region","vertexai","chroma"],"backgroundTag":"immutable-config-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}