chroma-core/chroma · error · TypeError

Select keys must be a list/tuple/set, got

Error message

Select keys must be a list/tuple/set, got {type(keys).__name__}

What it means

Raised during Select construction (from_dict or __init__) when the keys value is not a list, tuple, or set — e.g. a single key string or a dict was passed where an iterable collection of keys is required.

Solutions

  1. Pass keys as a list of strings: {"keys": ["#document"]}
  2. Check that a single string was not passed instead of a list of strings
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at chromadb/execution/expression/operator.py:1290 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/68eff62a98b3159f. Report an issue: GitHub.

Appendix: source

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

            else:
                key_strings.append(k)
        # Remove duplicates while preserving order
        return {"keys": list(dict.fromkeys(key_strings))}

    @staticmethod
    def from_dict(data: Dict[str, Any]) -> "Select":
        """Create Select from dictionary.

        Examples:
        - {"keys": ["#document", "#score"]} -> Select(keys={Key.DOCUMENT, Key.SCORE})
        - {"keys": ["title", "author"]} -> Select(keys={"title", "author"})
        """
        if not isinstance(data, dict):
            raise TypeError(f"Expected dict for Select, got {type(data).__name__}")

        keys = data.get("keys", [])
        if not isinstance(keys, (list, tuple, set)):
            raise TypeError(
                f"Select keys must be a list/tuple/set, got {type(keys).__name__}"
            )

        # Validate and convert each key
        key_list = []
        for k in keys:
            if not isinstance(k, str):
                raise TypeError(f"Select key must be a string, got {type(k).__name__}")

            # Map special keys to Key instances
            if k == "#id":
                key_list.append(Key.ID)
            elif k == "#document":
                key_list.append(Key.DOCUMENT)
            elif k == "#embedding":
                key_list.append(Key.EMBEDDING)
            elif k == "#metadata":
                key_list.append(Key.METADATA)

View on GitHub (pinned to aecdd12c8a)