{"record":{"id":"81419841e2e1e4e7","repo":"chroma-core/chroma","slug":"invaliddimension-814198","errorCode":"InvalidDimension","errorMessage":"Dimensionality of ({dim}) does not match indexdimensionality ({self._dimensionality})","messagePattern":"Dimensionality of \\((.+?)\\) does not match indexdimensionality \\((.+?)\\)","errorType":"validation","errorClass":"InvalidDimensionException","httpStatus":null,"severity":"error","filePath":"chromadb/segment/impl/vector/local_hnsw.py","lineNumber":230,"sourceCode":"            max_elements=DEFAULT_CAPACITY,\n            ef_construction=self._params.construction_ef,\n            M=self._params.M,\n        )\n        index.set_ef(self._params.search_ef)\n        index.set_num_threads(self._params.num_threads)\n\n        self._index = index\n        self._dimensionality = dimensionality\n\n    @trace_method(\"LocalHnswSegment._ensure_index\", OpenTelemetryGranularity.ALL)\n    def _ensure_index(self, n: int, dim: int) -> None:\n        \"\"\"Create or resize the index as necessary to accomodate N new records\"\"\"\n        if not self._index:\n            self._dimensionality = dim\n            self._init_index(dim)\n        else:\n            if dim != self._dimensionality:\n                raise InvalidDimensionException(\n                    f\"Dimensionality of ({dim}) does not match index\"\n                    + f\"dimensionality ({self._dimensionality})\"\n                )\n\n        index = cast(hnswlib.Index, self._index)\n\n        if (self._total_elements_added + n) > index.get_max_elements():\n            new_size = int(\n                (self._total_elements_added + n) * self._params.resize_factor\n            )\n            index.resize_index(max(new_size, DEFAULT_CAPACITY))\n\n    @trace_method(\"LocalHnswSegment._apply_batch\", OpenTelemetryGranularity.ALL)\n    def _apply_batch(self, batch: Batch) -> None:\n        \"\"\"Apply a batch of changes, as atomically as possible.\"\"\"\n        deleted_ids = batch.get_deleted_ids()\n        written_ids = batch.get_written_ids()\n        vectors_to_write = batch.get_written_vectors(written_ids)","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/segment/impl/vector/local_hnsw.py#L212-L248","documentation":"Error \"Dimensionality of ({dim}) does not match indexdimensionality ({self._dimensionality})\" thrown in chroma-core/chroma.","triggerScenarios":"Thrown at chromadb/segment/impl/vector/local_hnsw.py:230 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}