chroma-core/chroma · error · ValueError

Operator dict for field

Error message

Operator dict for field '{field}' cannot be empty

What it means

Raised by Where.from_dict when a single-field condition is given as an empty dict for that field, e.g. {"field": {}}. An operator dict must contain at least one operator ($eq, $gt, $in, ...) with its comparison value.

Solutions

  1. Provide an operator such as {"field": {"$eq": value}}
  2. Use a bare value for simple equality: {"field": value}
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

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

            field, condition = next(iter(data.items()))

            if not isinstance(field, str):
                raise TypeError(
                    f"Field name must be a string, got {type(field).__name__}"
                )

            if isinstance(condition, dict):
                # Operator-based condition
                if not condition:
                    raise ValueError(
                        f"Operator dict for field '{field}' cannot be empty"
                    )
                if len(condition) != 1:
                    raise ValueError(
                        f"Operator dict for field '{field}' must contain exactly one operator"
                    )

                op, value = next(iter(condition.items()))

                if op == "$eq":
                    return Key(field) == value
                elif op == "$ne":
                    return Key(field) != value
                elif op == "$gt":
                    return Key(field) > value
                elif op == "$gte":
                    return Key(field) >= value
                elif op == "$lt":

View on GitHub (pinned to aecdd12c8a)