chroma-core/chroma · error · ValueError

embedding_function must be a callable SparseEmbeddingFunctio

Error message

embedding_function must be a callable SparseEmbeddingFunction or None

What it means

Error "embedding_function must be a callable SparseEmbeddingFunction or None" thrown in chroma-core/chroma.

Source

Thrown at chromadb/api/types.py:1792

        if v.startswith("#") and v != "#document":
            raise ValueError(
                "source_key cannot begin with '#'. "
                "The only valid key starting with '#' is Key.DOCUMENT or '#document'."
            )

        return v  # type: ignore[no-any-return]

    @field_validator("embedding_function", mode="before")
    @classmethod
    def validate_embedding_function_field(cls, v: Any) -> Any:
        # Validate sparse vector function for sparse vector index
        if v is None:
            return v
        if callable(v):
            # Use the sparse vector function validation
            validate_sparse_embedding_function(v)
            return v
        raise ValueError(
            "embedding_function must be a callable SparseEmbeddingFunction or None"
        )


class StringInvertedIndexConfig(BaseModel):
    """Configuration for string inverted index."""

    model_config = {"extra": "forbid"}

    pass


class IntInvertedIndexConfig(BaseModel):
    """Configuration for integer inverted index."""

    model_config = {"extra": "forbid"}

    pass

View on GitHub (pinned to aecdd12c8a)

When it happens

Trigger: Thrown at chromadb/api/types.py:1792 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/e9f4ec628de78a9e. Report an issue: GitHub.