mem0ai/mem0 · error · ValueError
Vector with id {vector_id} not found in collection {self.col
Error message
Vector with id {vector_id} not found in collection {self.collection_name} What it means
Raised by MilvusVectorStore.update() when only one of vector/payload is supplied, so the store must fetch the existing record to fill in the other, but the Milvus client returns no entity for that vector_id in the configured collection. It is a precondition failure: the update path cannot reconstruct the full record because nothing exists under that ID.
Source
Thrown at mem0/vector_stores/milvus.py:293
Args:
vector_id (str): ID of the vector to delete.
"""
self.client.delete(collection_name=self.collection_name, ids=[vector_id])
def update(self, vector_id=None, vector=None, payload=None):
"""
Update a vector and its payload.
Args:
vector_id (str): ID of the vector to update.
vector (List[float], optional): Updated vector.
payload (Dict, optional): Updated payload.
"""
if vector is None or payload is None:
existing = self.client.get(collection_name=self.collection_name, ids=vector_id)
if not existing:
raise ValueError(f"Vector with id {vector_id} not found in collection {self.collection_name}")
if vector is None:
vector = existing[0].get("vectors")
if vector is None:
raise ValueError(f"Existing record {vector_id} has no vector data")
if payload is None:
payload = existing[0].get("metadata")
schema = {"id": vector_id, "vectors": vector, "metadata": payload}
if self._has_bm25_schema:
text = ""
if payload:
text = (payload.get("text_lemmatized") or payload.get("data", ""))[:65535]
schema["text"] = text
self.client.upsert(collection_name=self.collection_name, data=schema)
def get(self, vector_id) -> Optional[OutputData]:
"""
Retrieve a vector by ID.View on GitHub (pinned to 001c235229)
Solutions
- Verify the record exists first: call vector_store.get(vector_id) and handle a None result before updating
- Check that collection_name in the Milvus config matches the collection the original insert targeted
- If the memory was deleted upstream, drop the stale reference instead of updating it
- For very fresh writes, retry the update after the Milvus flush/consistency interval
Example fix
// before
store.update(vector_id=memory_id, payload=new_payload)
// after
if store.get(memory_id) is None:
raise KeyError(f"memory {memory_id} no longer exists; refresh history")
store.update(vector_id=memory_id, payload=new_payload) Defensive patterns
Strategy: validation
Validate before calling
existing = milvus_store.get(vector_id)
if existing is None:
raise KeyError(f"vector {vector_id} not found; cannot partial-update")
milvus_store.update(vector_id=vector_id, vector=vec, payload=payload) Try / catch
try:
store.update(vector_id=vid, payload=p)
except ValueError as e:
if "not found in collection" in str(e):
# treat as deleted upstream: drop stale reference, re-add instead of update
store.insert(vectors=[vec], payloads=[p], ids=[vid])
else:
raise Prevention
- Check existence with get() before any partial update
- Persist collection_name with stored IDs so they are always used against the same collection
- After deleting memories, invalidate cached memory IDs in the application layer
When it happens
Trigger: Calling mem0's Milvus vector store update(vector_id=..., vector=None or payload=None) after the memory was deleted, after a collection reset/recreation, or with an ID from a different collection/environment. Also occurs when MilvusGetResult comes back empty because the flush/consistency lag means the record is not yet visible.
Common situations: Stale memory IDs held by an application after Mem0's memory history was cleared; pointing the vector store config at a different collection name or Milvus instance than the one that wrote the data; updating a memory immediately after insertion before consistency kicks in.
Related errors
- Invalid filter key: ${JSON.stringify(key)}
- Filter value for ${JSON.stringify(key)} must be a string, nu
- The 'pymilvus' library is required. Please install it using
- Existing record {vector_id} has no vector data
- AWS Bedrock model ${this.model} returned no embedding for on
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/2b1b652e525dcfec.
Report an issue: GitHub.