{"record":{"id":"61f426a699118e9f","repo":"MemPalace/mempalace","slug":"add-ids-must-be-unique-61f426","errorCode":null,"errorMessage":"add ids must be unique","messagePattern":"add ids must be unique","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/pgvector.py","lineNumber":967,"sourceCode":"        pushdown = None if _requires_local_filter(where, where_document) else where\n        rows = self._scroll(where=pushdown, with_embedding=with_embedding)\n        id_set = set(ids) if ids is not None else None\n        return [\n            row\n            for row in rows\n            if (id_set is None or row[\"id\"] in id_set)\n            and _matches_where(row[\"metadata\"], where)\n            and _matches_where_document(row[\"document\"], where_document)\n        ]\n\n    def add(self, *, documents, ids, metadatas=None, embeddings=None):\n        _validate_write_batch(\n            documents=documents, ids=ids, metadatas=metadatas, embeddings=embeddings\n        )\n        if embeddings is None:\n            raise ValueError(\"pgvector requires explicit embeddings\")\n        if len(set(ids)) != len(ids):\n            raise ValueError(\"add ids must be unique\")\n        existing = self.get(ids=list(ids), include=[])\n        if existing.ids:\n            raise ValueError(f\"ids already exist in pgvector collection: {existing.ids}\")\n        self.upsert(documents=documents, ids=ids, metadatas=metadatas, embeddings=embeddings)\n\n    def upsert(self, *, documents, ids, metadatas=None, embeddings=None):\n        _validate_write_batch(\n            documents=documents, ids=ids, metadatas=metadatas, embeddings=embeddings\n        )\n        if embeddings is None:\n            raise ValueError(\"pgvector requires explicit embeddings\")\n        vectors, dimension = _normalize_vectors(embeddings)\n        self._ensure_table(dimension)\n        metadatas = metadatas or [{} for _ in ids]\n        rows = [\n            {\n                \"id\": str(doc_id),\n                \"document\": str(doc),","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L949-L985","documentation":"Error \"add ids must be unique\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/backends/pgvector.py:967 when the library encounters an invalid state.","commonSituations":"Upstream chunker emitted duplicate drawer ids in one batch.","solutions":["Deduplicate ids before calling add; each id may appear only once per batch"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}