chroma-core/chroma · error · TypeError

$not_contains on #document requires a string pattern

Error message

$not_contains on #document requires a string pattern

What it means

Error "$not_contains on #document requires a string pattern" thrown in chroma-core/chroma.

Source

Thrown at chromadb/execution/expression/operator.py:517

            Key("tags").contains("action")              # metadata array contains
            Key("scores").contains(42)                  # metadata array contains
        """
        if self.name == "#document" and not isinstance(value, str):
            raise TypeError("$contains on #document requires a string pattern")
        return Contains(self.name, value)

    def not_contains(self, value: LiteralValue) -> NotContains:
        """Check if field does not contain a value.

        On Key.DOCUMENT: excludes documents containing the substring.
        On metadata fields: checks that the array field does not contain the scalar value.

        Examples:
            Key.DOCUMENT.not_contains("deprecated")  # document substring exclusion
            Key("tags").not_contains("draft")         # metadata array not-contains
        """
        if self.name == "#document" and not isinstance(value, str):
            raise TypeError("$not_contains on #document requires a string pattern")
        return NotContains(self.name, value)


# Initialize predefined key constants
Key.ID = Key("#id")
Key.DOCUMENT = Key("#document")
Key.EMBEDDING = Key("#embedding")
Key.METADATA = Key("#metadata")
Key.SCORE = Key("#score")

# Alias for Key
K = Key


@dataclass
class Filter:
    user_ids: Optional[IDs] = None
    where: Optional[Any] = None  # Old Where type from chromadb.types

View on GitHub (pinned to aecdd12c8a)

When it happens

Trigger: Thrown at chromadb/execution/expression/operator.py:517 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/f8d1be3ada627139. Report an issue: GitHub.