{"record":{"id":"b980ae47d296e224","repo":"MemPalace/mempalace","slug":"ids-already-exist-in-pgvector-collection-existin","errorCode":null,"errorMessage":"ids already exist in pgvector collection: {existing.ids}","messagePattern":"ids already exist in pgvector collection: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/pgvector.py","lineNumber":970,"sourceCode":"        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),\n                \"metadata\": _jsonable_metadata(meta),\n                \"embedding\": vector,\n                \"updated_at\": _utcnow(),","sourceCodeStart":952,"sourceCodeEnd":988,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L952-L988","documentation":"Error \"ids already exist in pgvector collection: {existing.ids}\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/backends/pgvector.py:970 when the library encounters an invalid state.","commonSituations":"Re-adding drawers that already exist in the table.","solutions":["Use update/upsert for existing ids, or delete the conflicting ids first"],"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-15T22:17:37.221Z"}