mem0ai/mem0 · error · ValueError
Invalid docstore value type: {type(value)}, expected dict
Error message
Invalid docstore value type: {type(value)}, expected dict What it means
Raised while validating docstore entries: a value (the payload) is not a dict. Every docstore entry must map an id to a payload dict (the memory metadata). ValueError raised during FAISS load.
Source
Thrown at mem0/vector_stores/faiss.py:109
ValueError: If the data structure is invalid.
"""
if not isinstance(data, tuple) or len(data) != 2:
raise ValueError("Invalid docstore format: expected tuple of (docstore, index_to_id)")
docstore, index_to_id = data
if not isinstance(docstore, dict):
raise ValueError("Invalid docstore format: docstore must be a dict")
if not isinstance(index_to_id, dict):
raise ValueError("Invalid docstore format: index_to_id must be a dict")
# Validate docstore entries
for key, value in docstore.items():
if not isinstance(key, str):
raise ValueError(f"Invalid docstore key type: {type(key)}, expected str")
if not isinstance(value, dict):
raise ValueError(f"Invalid docstore value type: {type(value)}, expected dict")
# Validate index_to_id entries
for key, value in index_to_id.items():
if not isinstance(key, int):
raise ValueError(f"Invalid index_to_id key type: {type(key)}, expected int")
if not isinstance(value, str):
raise ValueError(f"Invalid index_to_id value type: {type(value)}, expected str")
return docstore, index_to_id
class OutputData(BaseModel):
id: Optional[str] # memory id
score: Optional[float] # distance
payload: Optional[Dict] # metadata
class FAISS(VectorStoreBase):View on GitHub (pinned to 001c235229)
Solutions
- Convert each non-dict payload to a dict (e.g. {'text': doc.page_content, 'metadata': doc.metadata}) in a migration script
- Delete and rebuild the store via mem0 add() calls
- Validate the file offline with a loop asserting isinstance(v, dict) before constructing FAISS
Example fix
# before
# payload stored as a raw string
# after
payloads = {k: (v if isinstance(v, dict) else {'data': v}) for k, v in docstore.items()} Defensive patterns
Strategy: validation
Validate before calling
data[0] = {k: (v if isinstance(v, dict) else {'data': v}) for k, v in data[0].items()} Type guard
def docstore_values_are_dicts(d) -> bool:
return isinstance(d, dict) and all(isinstance(v, dict) for v in d.values()) Prevention
- Store only plain-dict payloads via mem0's add API
- Convert foreign Document objects to dicts during migrations
When it happens
Trigger: A persisted docstore where a payload is a string, list, or LangChain Document instead of a dict — typically from converting another framework's FAISS store to mem0's format.
Common situations: Langchain-to-mem0 migrations where Document objects were serialized raw; hand-crafted JSON payloads; partial schema changes between versions.
Related errors
- Invalid docstore format: docstore must be a dict
- Invalid docstore key type: {type(key)}, expected str
- Invalid index_to_id value type: {type(value)}, expected str
- The parameter 'use_compression' is no longer supported. Plea
- Invalid distance_strategy. Must be one of: 'euclidean', 'inn
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/158fd09a51cf312a.
Report an issue: GitHub.