MemPalace/mempalace · error · ValueError
add ids must be unique
Error message
add ids must be unique
What it means
Error "add ids must be unique" thrown in MemPalace/mempalace.
Source
Thrown at mempalace/backends/pgvector.py:967
pushdown = None if _requires_local_filter(where, where_document) else where
rows = self._scroll(where=pushdown, with_embedding=with_embedding)
id_set = set(ids) if ids is not None else None
return [
row
for row in rows
if (id_set is None or row["id"] in id_set)
and _matches_where(row["metadata"], where)
and _matches_where_document(row["document"], where_document)
]
def add(self, *, documents, ids, metadatas=None, embeddings=None):
_validate_write_batch(
documents=documents, ids=ids, metadatas=metadatas, embeddings=embeddings
)
if embeddings is None:
raise ValueError("pgvector requires explicit embeddings")
if len(set(ids)) != len(ids):
raise ValueError("add ids must be unique")
existing = self.get(ids=list(ids), include=[])
if existing.ids:
raise ValueError(f"ids already exist in pgvector collection: {existing.ids}")
self.upsert(documents=documents, ids=ids, metadatas=metadatas, embeddings=embeddings)
def upsert(self, *, documents, ids, metadatas=None, embeddings=None):
_validate_write_batch(
documents=documents, ids=ids, metadatas=metadatas, embeddings=embeddings
)
if embeddings is None:
raise ValueError("pgvector requires explicit embeddings")
vectors, dimension = _normalize_vectors(embeddings)
self._ensure_table(dimension)
metadatas = metadatas or [{} for _ in ids]
rows = [
{
"id": str(doc_id),
"document": str(doc),View on GitHub (pinned to 06cb6987f0)
Solutions
- Deduplicate ids before calling add; each id may appear only once per batch
When it happens
Trigger: Thrown at mempalace/backends/pgvector.py:967 when the library encounters an invalid state.
Common situations: Upstream chunker emitted duplicate drawer ids in one batch.
AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15).
Data as JSON: /api/errors/61f426a699118e9f.
Report an issue: GitHub.