{"record":{"id":"fe711e27199be532","repo":"mem0ai/mem0","slug":"no-docstore-found-at-docstore-path-or-json-docs","errorCode":null,"errorMessage":"No docstore found at {docstore_path} or {json_docstore_path}","messagePattern":"No docstore found at (.+?) or (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/faiss.py","lineNumber":217,"sourceCode":"                logger.info(f\"Loaded FAISS index from {index_path} with {self.index.ntotal} vectors (JSON format)\")\n\n            elif os.path.exists(docstore_path):\n                # Load from legacy pickle using safe unpickler\n                # This prevents arbitrary code execution from malicious pickle files\n                logger.warning(\n                    f\"Loading legacy pickle docstore from {docstore_path}. \"\n                    f\"Consider migrating to JSON format for better security.\"\n                )\n                data = _safe_pickle_load(docstore_path)\n                self.docstore, self.index_to_id = _validate_docstore_structure(data)\n                logger.info(f\"Loaded FAISS index from {index_path} with {self.index.ntotal} vectors (pickle format)\")\n\n                # Auto-migrate to JSON format\n                self._save()\n                logger.info(f\"Migrated docstore to JSON format: {json_docstore_path}\")\n\n            else:\n                raise FileNotFoundError(f\"No docstore found at {docstore_path} or {json_docstore_path}\")\n\n        except pickle.UnpicklingError as e:\n            logger.error(f\"Security error loading FAISS docstore: {e}\")\n            raise ValueError(f\"Failed to load FAISS docstore: potentially malicious pickle file. {e}\") from e\n        except Exception as e:\n            logger.warning(f\"Failed to load FAISS index: {e}\")\n            self.docstore = {}\n            self.index_to_id = {}\n\n    def _save(self):\n        \"\"\"Save FAISS index and docstore to disk using JSON format (secure).\"\"\"\n        if not self.path or not self.index:\n            return\n\n        try:\n            os.makedirs(self.path, exist_ok=True)\n            index_path = f\"{self.path}/{self.collection_name}.faiss\"\n            json_docstore_path = f\"{self.path}/{self.collection_name}.json\"","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/faiss.py#L199-L235","documentation":"Raised during FAISS load when an index file exists but neither the legacy pickle docstore (faiss.docstore) nor the JSON docstore (faiss.docstore.json) is present at the expected path. Mem0 refuses to use a bare .index file because payloads would be lost. FileNotFoundError.","triggerScenarios":"Configuring FAISS with a path containing only the index file (e.g. after a partial copy, or someone deleted the docstore files), or a path where files are named differently than mem0 expects.","commonSituations":"Copying a collection directory incompletely between machines/containers; backup scripts that glob only *.index; OS-level case-sensitivity mismatch in filenames; empty path pointing at the wrong directory.","solutions":["Restore or copy faiss.docstore.json (or legacy faiss.docstore) alongside the index file into the configured path","If the docstore is unrecoverable, delete the index too and rebuild the collection from source memories","Check the collection path config (absolute vs relative, trailing slash) and list the directory to confirm expected filenames"],"exampleFix":"# before\nvs = FAISS(VectorStoreConfig(provider='faiss', config=FAISSConfig(path='/data/mem', collection_name='mem')))\n# FileNotFoundError if /data/mem lacks faiss.docstore.json\n\n# after\nimport os\nassert os.path.exists('/data/mem/faiss.index')\nassert os.path.exists('/data/mem/faiss.docstore.json'), 'copy the docstore too'","handlingStrategy":"validation","validationCode":"import os\n\ndef faiss_store_complete(path):\n    return all(\n        os.path.exists(os.path.join(path, f))\n        for f in ('faiss.index', 'faiss.docstore.json')\n    )","typeGuard":null,"tryCatchPattern":"try:\n    vs = FAISS(config)\nexcept FileNotFoundError as e:\n    if 'No docstore found' in str(e):\n        raise RuntimeError(f'Incomplete FAISS store at {config.path}: {e}') from e\n    raise","preventionTips":["Copy collection directories atomically (index + docstore files together)","Include faiss.docstore.json in backup globs, not just *.index","Verify expected filenames exist before pointing FAISS at a path"],"tags":["faiss","vector-store","file-not-found","persistence"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}