{"record":{"id":"7d6165d7247d14ce","repo":"chroma-core/chroma","slug":"sparsevector-indices-and-values-must-have-the-same","errorCode":null,"errorMessage":"SparseVector indices and values must have the same length, got {len(self.indices)} indices and {len(self.values)} values","messagePattern":"SparseVector indices and values must have the same length, got (.+?) indices and (.+?) values","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/base_types.py","lineNumber":45,"sourceCode":"\n    indices: List[int]\n    values: List[float]\n    labels: Optional[List[str]] = None\n\n    def __post_init__(self) -> None:\n        \"\"\"Validate sparse vector structure.\"\"\"\n        if not isinstance(self.indices, list):\n            raise ValueError(\n                f\"Expected SparseVector indices to be a list, got {type(self.indices).__name__}\"\n            )\n\n        if not isinstance(self.values, list):\n            raise ValueError(\n                f\"Expected SparseVector values to be a list, got {type(self.values).__name__}\"\n            )\n\n        if len(self.indices) != len(self.values):\n            raise ValueError(\n                f\"SparseVector indices and values must have the same length, \"\n                f\"got {len(self.indices)} indices and {len(self.values)} values\"\n            )\n\n        if self.labels is not None:\n            if not isinstance(self.labels, list):\n                raise ValueError(\n                    f\"Expected SparseVector labels to be a list, got {type(self.labels).__name__}\"\n                )\n            if len(self.labels) != len(self.indices):\n                raise ValueError(\n                    f\"SparseVector labels must have the same length as indices and values, \"\n                    f\"got {len(self.labels)} labels, {len(self.indices)} indices\"\n                )\n\n        for i, idx in enumerate(self.indices):\n            if not isinstance(idx, int):\n                raise ValueError(","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/base_types.py#L27-L63","documentation":"__post_init__ structural check on SparseVector: indices and values must be parallel arrays of equal length (one value per index). This error fires when the two lists diverge in length, meaning the sparse vector is malformed and some indices would have no value or vice versa.","triggerScenarios":"Thrown at chromadb/base_types.py:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure each index has exactly one corresponding value","Rebuild the sparse vector from its source so indices and values are derived from the same iteration","Check for off-by-one slicing or partial updates of one list but not the other"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","contentChangedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}