chroma-core/chroma · error · ValueError
Expected SparseVector labels to be a list, got
Error message
Expected SparseVector labels to be a list, got {type(self.labels).__name__} What it means
Raised by SparseVector.__post_init__ when the labels attribute is not a Python list (e.g. a numpy array, tuple, or scalar was passed). Part of the constructor's self-validation that ensures labels, indices, and values are plain lists of matching length.
Solutions
- Convert labels with list(labels) before constructing SparseVector
- Pass labels as a plain Python list of strings, or omit it entirely (default None)
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at chromadb/base_types.py:52 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/fc608496f1484fa8.
Report an issue: GitHub.
Appendix: source
Thrown at chromadb/base_types.py:52
if not isinstance(self.indices, list):
raise ValueError(
f"Expected SparseVector indices to be a list, got {type(self.indices).__name__}"
)
if not isinstance(self.values, list):
raise ValueError(
f"Expected SparseVector values to be a list, got {type(self.values).__name__}"
)
if len(self.indices) != len(self.values):
raise ValueError(
f"SparseVector indices and values must have the same length, "
f"got {len(self.indices)} indices and {len(self.values)} values"
)
if self.labels is not None:
if not isinstance(self.labels, list):
raise ValueError(
f"Expected SparseVector labels to be a list, got {type(self.labels).__name__}"
)
if len(self.labels) != len(self.indices):
raise ValueError(
f"SparseVector labels must have the same length as indices and values, "
f"got {len(self.labels)} labels, {len(self.indices)} indices"
)
for i, idx in enumerate(self.indices):
if not isinstance(idx, int):
raise ValueError(
f"SparseVector indices must be integers, got {type(idx).__name__} at position {i}"
)
if idx < 0:
raise ValueError(
f"SparseVector indices must be non-negative, got {idx} at position {i}"
)
View on GitHub (pinned to aecdd12c8a)