{"record":{"id":"eed0b8d3910243b0","repo":"mem0ai/mem0","slug":"invalid-index-to-id-value-type-type-value-exp","errorCode":null,"errorMessage":"Invalid index_to_id value type: {type(value)}, expected str","messagePattern":"Invalid index_to_id value type: (.+?), expected str","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/faiss.py","lineNumber":116,"sourceCode":"    if not isinstance(docstore, dict):\n        raise ValueError(\"Invalid docstore format: docstore must be a dict\")\n\n    if not isinstance(index_to_id, dict):\n        raise ValueError(\"Invalid docstore format: index_to_id must be a dict\")\n\n    # Validate docstore entries\n    for key, value in docstore.items():\n        if not isinstance(key, str):\n            raise ValueError(f\"Invalid docstore key type: {type(key)}, expected str\")\n        if not isinstance(value, dict):\n            raise ValueError(f\"Invalid docstore value type: {type(value)}, expected dict\")\n\n    # Validate index_to_id entries\n    for key, value in index_to_id.items():\n        if not isinstance(key, int):\n            raise ValueError(f\"Invalid index_to_id key type: {type(key)}, expected int\")\n        if not isinstance(value, str):\n            raise ValueError(f\"Invalid index_to_id value type: {type(value)}, expected str\")\n\n    return docstore, index_to_id\n\n\nclass OutputData(BaseModel):\n    id: Optional[str]  # memory id\n    score: Optional[float]  # distance\n    payload: Optional[Dict]  # metadata\n\n\nclass FAISS(VectorStoreBase):\n    def __init__(\n        self,\n        collection_name: str,\n        path: Optional[str] = None,\n        distance_strategy: str = \"euclidean\",\n        normalize_L2: bool = False,\n        embedding_model_dims: int = 1536,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/faiss.py#L98-L134","documentation":"Raised while validating index_to_id entries: a value (the memory id for a FAISS row) is not a str. Ids must be strings to match docstore keys. ValueError raised at load.","triggerScenarios":"A persisted index_to_id whose values are ints or uuid objects, e.g. a store built with integer ids or unpickled uuid.UUID values.","commonSituations":"Custom code that inserted rows with non-string ids; merging stores from different sources; older files created before strict validation existed.","solutions":["Stringify all index_to_id values (and docstore keys to match) in a migration pass","Rebuild the store using mem0's add API, which generates str(uuid4()) ids","Discard and re-index if ids cannot be recovered reliably"],"exampleFix":"# before\nindex_to_id = data[1]  # values may be ints\n\n# after\nindex_to_id = {k: str(v) for k, v in data[1].items()}\ndocstore = {str(k): v for k, v in data[0].items()}","handlingStrategy":"validation","validationCode":"data[1] = {k: str(v) for k, v in data[1].items()}\ndata[0] = {str(k): v for k, v in data[0].items()}  # keep both sides consistent","typeGuard":"def index_to_id_values_are_str(x) -> bool:\n    return isinstance(x, dict) and all(isinstance(v, str) for v in x.values())","tryCatchPattern":null,"preventionTips":["Always use string ids when inserting into FAISS stores","Validate both docstore keys and index_to_id values together after any transformation"],"tags":["faiss","vector-store","type-coercion","data-validation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}