chroma-core/chroma · error · ValueError
Aggregate dict cannot be empty
Error message
Aggregate dict cannot be empty
What it means
Raised by Aggregate.from_dict when the aggregate dict is empty ({}). At least one operator ($min_k or $max_k) with its parameters must be present to form a valid aggregation.
Solutions
- Include exactly one operator key in the dict, e.g. {"$max_k": {"keys": ["#score"], "k": 2}}
- If no aggregation is needed, omit the aggregate field instead of sending an empty dict
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at chromadb/execution/expression/operator.py:1413 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/ae1b82c6ed076048.
Report an issue: GitHub.
Appendix: source
Thrown at chromadb/execution/expression/operator.py:1413
"""
def to_dict(self) -> Dict[str, Any]:
"""Convert the Aggregate expression to a dictionary for JSON serialization"""
raise NotImplementedError("Subclasses must implement to_dict()")
@staticmethod
def from_dict(data: Dict[str, Any]) -> "Aggregate":
"""Create Aggregate expression from dictionary.
Supports:
- {"$min_k": {"keys": [...], "k": n}} -> MinK(keys=[...], k=n)
- {"$max_k": {"keys": [...], "k": n}} -> MaxK(keys=[...], k=n)
"""
if not isinstance(data, dict):
raise TypeError(f"Expected dict for Aggregate, got {type(data).__name__}")
if not data:
raise ValueError("Aggregate dict cannot be empty")
if len(data) != 1:
raise ValueError(
f"Aggregate dict must contain exactly one operator, got {len(data)}"
)
op = next(iter(data.keys()))
if op == "$min_k":
keys, k = _parse_k_aggregate(op, data)
return MinK(keys=keys, k=k)
elif op == "$max_k":
keys, k = _parse_k_aggregate(op, data)
return MaxK(keys=keys, k=k)
else:
raise ValueError(f"Unknown aggregate operator: {op}")
View on GitHub (pinned to aecdd12c8a)