{"record":{"id":"1e54296f53cdbc64","repo":"MemPalace/mempalace","slug":"label-length-len-value-does-not-match-ids-len-1e5429","errorCode":null,"errorMessage":"{label} length {len(value)} does not match ids length {n}","messagePattern":"(.+?) length (.+?) does not match ids length (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/qdrant.py","lineNumber":869,"sourceCode":"                        _PAYLOAD_METADATA: _jsonable_metadata(meta),\n                        \"updated_at\": _utcnow(),\n                    },\n                }\n            )\n        self._client.upsert_points(self._remote_collection, points)\n        self._backend._write_marker(self._palace, self._config)\n\n    def update(self, *, ids, documents=None, metadatas=None, embeddings=None):\n        if documents is None and metadatas is None and embeddings is None:\n            raise ValueError(\"update requires at least one of documents, metadatas, embeddings\")\n        n = len(ids)\n        for label, value in (\n            (\"documents\", documents),\n            (\"metadatas\", metadatas),\n            (\"embeddings\", embeddings),\n        ):\n            if value is not None and len(value) != n:\n                raise ValueError(f\"{label} length {len(value)} does not match ids length {n}\")\n        existing = self.get(ids=ids, include=[\"documents\", \"metadatas\", \"embeddings\"])\n        by_id = {\n            rid: (existing.documents[i], existing.metadatas[i], existing.embeddings[i])\n            for i, rid in enumerate(existing.ids)\n            if existing.embeddings is not None\n        }\n        out_ids = []\n        out_docs = []\n        out_metas = []\n        out_embeddings = []\n        for idx, doc_id in enumerate(ids):\n            if doc_id not in by_id:\n                continue\n            prev_doc, prev_meta, prev_embedding = by_id[doc_id]\n            out_ids.append(doc_id)\n            out_docs.append(documents[idx] if documents is not None else prev_doc)\n            meta = dict(prev_meta or {})\n            if metadatas is not None:","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/qdrant.py#L851-L887","documentation":"Raised by QdrantCollection.update() when any of the provided parallel arrays (documents, metadatas, embeddings) has a length different from the ids array. update() merges per-id, so every supplied array must align 1:1 with ids.","triggerScenarios":"Calling update(ids=['a','b','c'], metadatas=[m1]) or similar — e.g. passing a single metadata dict meant for all rows, or building arrays in a loop that appends conditionally so some rows are skipped.","commonSituations":"Caller passes one shared value instead of a per-id list (scalar/1-element broadcast mistake); array built with a filtered comprehension while ids weren't filtered; off-by-one in chunked update loops.","solutions":["Broadcast explicitly: metadatas = [meta] * len(ids) if you meant one value for all rows","Rebuild arrays with zip(ids, ...) so they cannot drift from ids","Add a pre-call assertion: assert all(v is None or len(v) == len(ids) for v in (documents, metadatas, embeddings))","The error message names the offending label — check that array's construction logic first"],"exampleFix":"# before\ncollection.update(ids=ids, metadatas=[{\"seen\": True}])  # 1 != len(ids)\n// after\ncollection.update(ids=ids, metadatas=[{\"seen\": True}] * len(ids))","handlingStrategy":"validation","validationCode":"assert all(v is None or len(v) == len(ids) for v in (documents, metadatas, embeddings))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build parallel arrays with zip(ids, ...) so they cannot drift","Broadcast single values explicitly: metadatas=[m] * len(ids)"],"tags":["validation","api-misuse","qdrant","batching"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}