chroma-core/chroma · error · ValueError

The project cannot be changed after the embedding function h

Error message

The project cannot be changed after the embedding function has been initialized.

What it means

GoogleGeminiEmbeddingFunction.validate_config_update rejects update payloads containing a 'project' key. The GCP project id is bound into the genai.Client at construction and determines billing/quota for Vertex deployments; changing it after initialization is not supported, so it is validated as immutable.

Source

Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:187

        return config

    def validate_config_update(
        self, old_config: Dict[str, Any], new_config: Dict[str, Any]
    ) -> None:
        if "model_name" in new_config:
            raise ValueError(
                "The model name cannot be changed after the embedding function has been initialized."
            )
        if "dimension" in new_config:
            raise ValueError(
                "The dimension cannot be changed after the embedding function has been initialized."
            )
        if "vertexai" in new_config:
            raise ValueError(
                "The vertexai cannot be changed after the embedding function has been initialized."
            )
        if "project" in new_config:
            raise ValueError(
                "The project cannot be changed after the embedding function has been initialized."
            )
        if "location" in new_config:
            raise ValueError(
                "The location cannot be changed after the embedding function has been initialized."
            )

    @staticmethod
    def validate_config(config: Dict[str, Any]) -> None:
        """
        Validate the configuration using the JSON schema.

        Args:
            config: Configuration to validate

        Raises:
            ValidationError: If the configuration does not match the schema
        """

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Rebuild the embedding function and collection against the new project and re-embed
  2. Remove the 'project' key from update payloads that only change mutable fields
  3. Keep project/location/model decisions stable per collection lifecycle

Example fix

# before
new_config = ef.get_config()  # contains "project": "old-project"
new_config["api_key_env_var"] = "GOOGLE_API_KEY"
ef.validate_config_update(old, new_config)  # ValueError: project immutable

# after
new_config = {"api_key_env_var": "GOOGLE_API_KEY"}
ef.validate_config_update(old, new_config)
Defensive patterns

Strategy: validation

Validate before calling

IMMUTABLE = {"model_name", "dimension", "vertexai", "project", "location"}

update = {k: v for k, v in desired_config.items() if k not in IMMUTABLE}
assert "project" not in update
ef.validate_config_update(old_config, update)

Type guard

from typing import Any, TypeGuard

MUTABLE_GEMINI_KEYS = {"api_key_env_var", "task_type"}

def is_mutable_update(cfg: Any) -> TypeGuard[dict]:
    return isinstance(cfg, dict) and set(cfg) <= MUTABLE_GEMINI_KEYS

Prevention

When it happens

Trigger: Attempting to move a Vertex-backed embedding function to another GCP project via config update; including 'project' in a payload built from ef.get_config() (which always emits the key).

Common situations: Reorganizing GCP projects or migrating billing accounts and trying to repoint an existing deployment in place; full-config copy used as an update payload.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/7fb96de3955db0a6. Report an issue: GitHub.