{"record":{"id":"1eff8b58affcc4c8","repo":"chroma-core/chroma","slug":"the-model-name-cannot-be-changed-after-the-embeddi","errorCode":null,"errorMessage":"The model name cannot be changed after the embedding function has been initialized.","messagePattern":"The model name cannot be changed after the embedding function has been initialized\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/amazon_bedrock_embedding_function.py","lineNumber":123,"sourceCode":"        else:\n            session = boto3.Session(**session_args)\n\n        return AmazonBedrockEmbeddingFunction(\n            session=session, model_name=model_name, **kwargs\n        )\n\n    def get_config(self) -> Dict[str, Any]:\n        return {\n            \"model_name\": self.model_name,\n            \"session_args\": self._session_args,\n            \"kwargs\": self.kwargs,\n        }\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\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, \"amazon_bedrock\")\n","sourceCodeStart":105,"sourceCodeEnd":139,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/amazon_bedrock_embedding_function.py#L105-L139","documentation":"When a collection's embedding function is replaced, chromadb calls update_ef.validate_config_update(old_config, new_config) via overwrite_embedding_function (chromadb/api/collection_configuration.py:711, reached from Collection.modify). AmazonBedrockEmbeddingFunction rejects any new_config that contains the \"model_name\" key, because changing the embedding model would make all existing vectors in the collection incompatible. Caveat: the guard checks key presence, not value change — and get_config() always includes \"model_name\" — so effectively any bedrock-to-bedrock embedding function update raises, even with an identical model.","triggerScenarios":"collection.modify(configuration=CollectionConfiguration(embedding_function=AmazonBedrockEmbeddingFunction(...))) on a collection whose current embedding function is also amazon_bedrock; overwrite_embedding_function passes the new function's get_config() (which always contains model_name) straight into this check.","commonSituations":"Trying to tweak session args or kwargs on an existing collection; attempting a model-version migration in place; copy-pasting the original constructor into a modify() call while debugging.","solutions":["Create a new collection with the desired bedrock model and re-embed your documents — model changes cannot be applied in place.","If you only meant to change other collection settings (metadata, hnsw config), call modify() without an embedding_function so this validation never runs.","If you believe unchanged model_name should be allowed, file an upstream issue: the check should compare old vs new values, not mere key presence."],"exampleFix":"# before: raises ValueError \"The model name cannot be changed...\"\nclient.get_collection(\"docs\", embedding_function=old_ef).modify(\n    configuration=CollectionConfiguration(\n        embedding_function=AmazonBedrockEmbeddingFunction(session=new_session)\n    )\n)\n\n# after: model is fixed per collection — make a new one and re-embed\nnew_col = client.create_collection(\"docs_v2\", embedding_function=AmazonBedrockEmbeddingFunction(session=new_session))\nfor batch in read_old_batches():\n    new_col.add(**batch)\n# or, to change only non-EF settings: col.modify(metadata={...}) with no embedding_function","handlingStrategy":"validation","validationCode":"from chromadb.utils.embedding_functions import AmazonBedrockEmbeddingFunction\n\ndef can_update_bedrock_ef(new_ef) -> bool:\n    try:\n        new_ef.validate_config_update(new_ef.get_config(), {k: v for k, v in new_ef.get_config().items() if k != \"model_name\"})\n        return True\n    except ValueError:\n        return False  # model_name change attempted — must create a new collection instead\n\nif can_update_bedrock_ef(new_ef):\n    col.modify(configuration=CollectionConfiguration(embedding_function=new_ef))\nelse:\n    raise RuntimeError(\"Bedrock model_name is fixed per collection; create a new collection and re-embed\")","typeGuard":null,"tryCatchPattern":"try:\n    col.modify(configuration=CollectionConfiguration(embedding_function=new_ef))\nexcept ValueError as e:\n    if \"model name cannot be changed\" in str(e):\n        # model is immutable per collection — migrate instead\n        new_col = client.create_collection(f\"{col.name}_v2\", embedding_function=new_ef)\n        migrate_documents(col, new_col)\n    else:\n        raise","preventionTips":["Treat the embedding model as part of a collection's identity: plan migrations as new collections plus re-embeds.","When calling modify(), pass only the settings you intend to change — omit embedding_function entirely for non-EF updates.","Wrap collection migrations in a script that checkpoints progress, since in-place model swaps are not possible."],"tags":["python","aws","bedrock","embedding-functions","immutable-field","collection-modify","chromadb"],"backgroundTag":"immutable-config-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}