chroma-core/chroma · error · ValueError

The task type cannot be changed after the embedding…

Error message

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

What it means

Raised in validate_config_update when a config update tries to change task_type after a Google embedding function was initialized. Immutable-config guard ensuring rebuilds stay consistent with persisted configuration.

Solutions

  1. Keep task_type unchanged across updates
  2. Create a new embedding function instance/collection if a different task_type is needed
  3. Omit task_type from the update payload
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:348 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

    def get_config(self) -> Dict[str, Any]:
        config: Dict[str, Any] = {
            "api_key_env_var": self.api_key_env_var,
            "model_name": self.model_name,
            "task_type": self.task_type,
        }
        if self.dimension is not None:
            config["dimension"] = self.dimension
        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 "task_type" in new_config:
            raise ValueError(
                "The task type 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."
            )

    @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)