{"record":{"id":"fba1c826e9e2ffb1","repo":"chroma-core/chroma","slug":"sparsevector-labels-must-have-the-same-length-as-i","errorCode":null,"errorMessage":"SparseVector labels must have the same length as indices and values, got {len(self.labels)} labels, {len(self.indices)} indices","messagePattern":"SparseVector labels must have the same length as indices and values, got (.+?) labels, (.+?) indices","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/base_types.py","lineNumber":56,"sourceCode":"\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(\n                    f\"SparseVector indices must be integers, got {type(idx).__name__} at position {i}\"\n                )\n            if idx < 0:\n                raise ValueError(\n                    f\"SparseVector indices must be non-negative, got {idx} at position {i}\"\n                )\n\n        for i, val in enumerate(self.values):\n            if not isinstance(val, (int, float)):\n                raise ValueError(\n                    f\"SparseVector values must be numbers, got {type(val).__name__} at position {i}\"","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/base_types.py#L38-L74","documentation":"__post_init__ structural check on SparseVector: when labels is supplied, it must be parallel to indices and values, so its length must equal len(indices). Fires when a shorter or longer label list is passed, which would leave some dimensions unlabeled or labels unmatched.","triggerScenarios":"Thrown at chromadb/base_types.py:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide exactly one label per index/value","Derive labels from the same source as indices to keep lengths in sync","Omit labels if per-dimension labels are not needed"],"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"}