chroma-core/chroma · error · TypeError
Field name must be a string, got
Error message
Field name must be a string, got {type(field).__name__} What it means
TypeError in Where.from_dict: the field name extracted from the where dict must be a string key, but a non-string key was found. Fires on dicts with non-string keys (ints, tuples) used as where filters.
Solutions
- Use string metadata field names as keys
- Check for JSON/YAML decoding that produced non-string keys
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at chromadb/execution/expression/operator.py:146 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/a77ff68d59621e55.
Report an issue: GitHub.
Appendix: source
Thrown at chromadb/execution/expression/operator.py:146
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(
f"Operator dict for field '{field}' must contain exactly one operator"
)
op, value = next(iter(condition.items()))
if op == "$eq":
return Key(field) == valueView on GitHub (pinned to aecdd12c8a)