chroma-core/chroma · error · ValueError

$or requires at least one condition

Error message

$or requires at least one condition

What it means

Raised by Where.from_dict when '$or' is provided as a list but the list contains zero conditions. An OR over no conditions is undefined, so at least one condition dict is required.

Solutions

  1. Include at least one condition in the $or list
  2. Drop the $or wrapper if no alternatives are actually needed
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

                raise ValueError("$and requires at least one condition")
            if len(data) > 1:
                raise ValueError(
                    "$and cannot be combined with other fields in the same dict"
                )

            conditions = [Where.from_dict(c) for c in data["$and"]]
            if len(conditions) == 1:
                return conditions[0]
            result = conditions[0]
            for c in conditions[1:]:
                result = result & c
            return result

        elif "$or" in data:
            if not isinstance(data["$or"], list):
                raise TypeError(f"$or must be a list, got {type(data['$or']).__name__}")
            if len(data["$or"]) == 0:
                raise ValueError("$or requires at least one condition")
            if len(data) > 1:
                raise ValueError(
                    "$or cannot be combined with other fields in the same dict"
                )

            conditions = [Where.from_dict(c) for c in data["$or"]]
            if len(conditions) == 1:
                return conditions[0]
            result = conditions[0]
            for c in conditions[1:]:
                result = result | c
            return result

        else:
            # Single field condition
            if len(data) != 1:
                raise ValueError(
                    f"Where dict must contain exactly one field, got {len(data)}"

View on GitHub (pinned to aecdd12c8a)