chroma-core/chroma · error · TypeError
GroupBy aggregate must be a dict, got
Error message
GroupBy aggregate must be a dict, got {type(aggregate_data).__name__} What it means
Raised by GroupBy.from_dict when the 'aggregate' field is not a dict — e.g. a string operator name was passed instead of an operator mapping like {"$min_k": {...}} that Aggregate.from_dict can parse.
Solutions
- Pass aggregate as a dict, e.g. {"$min_k": {"keys": ["#score"], "k": 3}}
- Serialize an Aggregate object with to_dict() instead of passing the object itself
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at chromadb/execution/expression/operator.py:1530 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/268ed798704c3bb4.
Report an issue: GitHub.
Appendix: source
Thrown at chromadb/execution/expression/operator.py:1530
# Empty dict returns default GroupBy (no grouping)
if not data:
return GroupBy()
# Non-empty dict requires keys and aggregate
if "keys" not in data:
raise ValueError("GroupBy requires 'keys' field")
if "aggregate" not in data:
raise ValueError("GroupBy requires 'aggregate' field")
keys = data["keys"]
if not isinstance(keys, (list, tuple)):
raise TypeError(f"GroupBy keys must be a list, got {type(keys).__name__}")
if not keys:
raise ValueError("GroupBy keys cannot be empty")
aggregate_data = data["aggregate"]
if not isinstance(aggregate_data, dict):
raise TypeError(
f"GroupBy aggregate must be a dict, got {type(aggregate_data).__name__}"
)
aggregate = Aggregate.from_dict(aggregate_data)
return GroupBy(keys=_strings_to_keys(keys), aggregate=aggregate)
View on GitHub (pinned to aecdd12c8a)