chroma-core/chroma · error · ValueError
Where dict must contain exactly one field, got
Error message
Where dict must contain exactly one field, got {len(data)} What it means
ValueError in Where.from_dict: a plain (non-$and/$or) where dict must contain exactly one field so it can be parsed as a single field condition; multiple fields were supplied. Multiple constraints must be expressed via $and.
Solutions
- Split into {"$and": [{"field1": v1}, {"field2": v2}]} for multiple constraints
- Keep only one field per condition dict
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at chromadb/execution/expression/operator.py:139 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/e86411d2f3c072ab.
Report an issue: GitHub.
Appendix: source
Thrown at chromadb/execution/expression/operator.py:139
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)}"
)
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(View on GitHub (pinned to aecdd12c8a)