chroma-core/chroma · error · TypeError
$min requires a list, got {type(ranks_data).__name__}
Error message
$min requires a list, got {type(ranks_data).__name__} What it means
$min folds a chain of pairwise minimums over rank expressions (the counterpart of $max, used e.g. to cap scores) and expects its payload to be a list of operand dicts. Rank.from_dict raises this TypeError when the $min payload is not a list/tuple — commonly a {'left','right'} dict in the $sub/$div style.
Source
Thrown at chromadb/execution/expression/operator.py:855
if not isinstance(ranks_data, (list, tuple)):
raise TypeError(
f"$max requires a list, got {type(ranks_data).__name__}"
)
if len(ranks_data) < 2:
raise ValueError(
f"$max requires at least 2 ranks, got {len(ranks_data)}"
)
ranks = [Rank.from_dict(r) for r in ranks_data]
result = ranks[0]
for r in ranks[1:]:
result = result.max(r)
return result
elif op == "$min":
ranks_data = data["$min"]
if not isinstance(ranks_data, (list, tuple)):
raise TypeError(
f"$min requires a list, got {type(ranks_data).__name__}"
)
if len(ranks_data) < 2:
raise ValueError(
f"$min requires at least 2 ranks, got {len(ranks_data)}"
)
ranks = [Rank.from_dict(r) for r in ranks_data]
result = ranks[0]
for r in ranks[1:]:
result = result.min(r)
return result
else:
raise ValueError(f"Unknown rank operator: {op}")
# Arithmetic operators
def __add__(self, other: Union["Rank", float, int]) -> "Sum":View on GitHub (pinned to aecdd12c8a)
Solutions
- Use the list form: {"$min": [rank_a, {"$val": 1.0}]}
- Convert pair dicts: {'$min': [pair['left'], pair['right']]}
- Build in Python as rank.min(1.0).to_dict()
- Guard: isinstance(expr['$min'], (list, tuple)) before Rank.from_dict
Example fix
# before
expr = {"$min": {"left": knn_rank, "right": {"$val": 1.0}}}
# after
expr = {"$min": [knn_rank, {"$val": 1.0}]} Defensive patterns
Strategy: validation
Validate before calling
def valid_min_expr(expr):
return (
isinstance(expr, dict) and set(expr) == {"$min"}
and isinstance(expr["$min"], (list, tuple))
)
if not valid_min_expr(rank_expr):
raise ValueError(f"$min payload must be a list: {rank_expr!r}") Type guard
def is_min_expr(d) -> bool:
return (isinstance(d, dict) and set(d) == {"$min"}
and isinstance(d["$min"], (list, tuple))) Try / catch
try:
rank = Rank.from_dict(rank_expr)
except (TypeError, ValueError) as e:
raise ValueError(f"invalid rank expression {rank_expr!r}: {e}") from e Prevention
- $min takes an operand list, not a left/right dict
- Emit caps from Python: rank.min(1.0).to_dict()
- Keep the payload-shape cheat sheet ($sum/$mul/$max/$min = list; $sub/$div = dict) near expression-building code
When it happens
Trigger: Rank.from_dict({'$min': {'left': a, 'right': b}}) or {'$min': 1.0} anywhere in a rank expression being deserialized.
Common situations: Hand-written cap expressions where the author alternates payload conventions; generators that emit the dict shape for every binary operator; JSON adapted from a $div example.
Related errors
- $sub requires a dict with 'left' and 'right', got {type(sub_
- $mul requires a list, got {type(ranks_data).__name__}
- $div requires a dict with 'left' and 'right', got {type(div_
- $abs requires a rank dict, got {type(child_data).__name__}
- $exp requires a rank dict, got {type(child_data).__name__}
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/ecc48cb7937d20a6.
Report an issue: GitHub.