chroma-core/chroma · error · TypeError

$in requires a list, got

Error message

$in requires a list, got {type(value).__name__}

What it means

Raised by Where.from_dict when the '$in' operator's value is not a list — e.g. a single scalar was passed instead of a collection of values for the membership test on that field.

Solutions

  1. Pass a list: {"field": {"$in": ["a", "b"]}}
  2. Use $eq for a single-value equality check instead
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at chromadb/execution/expression/operator.py:177 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/98887973bb653572. Report an issue: GitHub.

Appendix: source

Thrown at chromadb/execution/expression/operator.py:177

                    )

                op, value = next(iter(condition.items()))

                if op == "$eq":
                    return Key(field) == value
                elif op == "$ne":
                    return Key(field) != value
                elif op == "$gt":
                    return Key(field) > value
                elif op == "$gte":
                    return Key(field) >= value
                elif op == "$lt":
                    return Key(field) < value
                elif op == "$lte":
                    return Key(field) <= value
                elif op == "$in":
                    if not isinstance(value, list):
                        raise TypeError(
                            f"$in requires a list, got {type(value).__name__}"
                        )
                    return Key(field).is_in(value)
                elif op == "$nin":
                    if not isinstance(value, list):
                        raise TypeError(
                            f"$nin requires a list, got {type(value).__name__}"
                        )
                    return Key(field).not_in(value)
                elif op == "$contains":
                    if not isinstance(value, (str, int, float, bool)):
                        raise TypeError(
                            f"$contains requires a str, int, float, or bool, got {type(value).__name__}"
                        )
                    return Key(field).contains(value)
                elif op == "$not_contains":
                    if not isinstance(value, (str, int, float, bool)):
                        raise TypeError(

View on GitHub (pinned to aecdd12c8a)