chroma-core/chroma · error · KeyError

No such key: , valid keys are

Error message

No such key: {key}, valid keys are: {self.get_model_fields()}

What it means

Guard in the collection model's __setitem__ dict-style assignment: only known model fields (and 'configuration') may be set; an unrecognized key is rejected with the valid field list interpolated into the message.

Solutions

  1. Only set valid collection fields (e.g. name, metadata, dimension)
  2. Check the field name spelling against get_model_fields()
  3. Use metadata for custom key/value data instead of ad-hoc attributes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at chromadb/types.py:136 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/a5f40b6648704a17. Report an issue: GitHub.

Appendix: source

Thrown at chromadb/types.py:136

    def __getitem__(self, key: str) -> Optional[Any]:
        """Allows the collection to be treated as a dictionary"""
        if key == "configuration":
            return self.get_configuration()
        # For the other model attributes we allow the user to access them directly
        if key in self.get_model_fields():
            return getattr(self, key)
        return None

    # TODO: This doesn't check types.
    def __setitem__(self, key: str, value: Any) -> None:
        """Allows the collection to be treated as a dictionary"""
        # For the model attributes we allow the user to access them directly
        if key == "configuration":
            self.set_configuration(value)
        if key in self.get_model_fields():
            setattr(self, key, value)
        else:
            raise KeyError(
                f"No such key: {key}, valid keys are: {self.get_model_fields()}"
            )

    def __eq__(self, __value: object) -> bool:
        # Check that all the model fields are equal
        if not isinstance(__value, Collection):
            return False
        for field in self.get_model_fields():
            if getattr(self, field) != getattr(__value, field):
                return False
        return True

    def get_configuration(self) -> CollectionConfiguration:
        """Returns the configuration of the collection"""
        try:
            return load_collection_configuration_from_json(self.configuration_json)
        except Exception as e:
            raise ValueError(

View on GitHub (pinned to aecdd12c8a)