{"record":{"id":"3a4d328fd4308f2f","repo":"FoundationAgents/MetaGPT","slug":"indexrepo-path-self-persist-path-name-not-exist","errorCode":null,"errorMessage":"IndexRepo {Path(self.persist_path).name} not exists.","messagePattern":"IndexRepo (.+?) not exists\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/tools/libs/index_repo.py","lineNumber":325,"sourceCode":"                    pathnames.append(j)\n\n        logger.debug(f\"{pathnames}, excludes:{excludes})\")\n        return pathnames, excludes\n\n    async def _search(self, query: str, filters: Set[str]) -> List[NodeWithScore]:\n        \"\"\"Perform a search for the given query using the index.\n\n        Args:\n            query (str): The search query.\n            filters (Set[str]): A set of filenames to filter the search results.\n\n        Returns:\n            List[NodeWithScore]: A list of nodes with scores matching the query.\n        \"\"\"\n        if not filters:\n            return []\n        if not Path(self.persist_path).exists():\n            raise ValueError(f\"IndexRepo {Path(self.persist_path).name} not exists.\")\n        Context()\n        engine = SimpleEngine.from_index(\n            index_config=FAISSIndexConfig(persist_path=self.persist_path),\n            retriever_configs=[FAISSRetrieverConfig()],\n        )\n        rsp = await engine.aretrieve(query)\n        return [i for i in rsp if i.metadata.get(\"file_path\") in filters]\n\n    def _is_fingerprint_changed(self, filename: Union[str, Path], content: str) -> bool:\n        \"\"\"Check if the fingerprint of the given document content has changed.\n\n        Args:\n            filename (Union[str, Path]): The filename of the document.\n            content (str): The content of the document.\n\n        Returns:\n            bool: True if the fingerprint has changed, False otherwise.\n        \"\"\"","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/tools/libs/index_repo.py#L307-L343","documentation":"ValueError from IndexRepo._search_with_index: a filename filter was supplied but the FAISS index directory at self.persist_path does not exist, so there is no persisted index to load via SimpleEngine.from_index. The repository is search-only here; indexes must be created beforehand (e.g. via Editor's write operations that feed IndexRepo).","triggerScenarios":"Constructing IndexRepo(persist_path=..., root_path=...) for a directory that was never indexed, then awaiting search(query, filenames=[...]) with a non-empty filter.","commonSituations":"Searching a fresh workspace before any indexing run; the index directory was cleaned/deleted; persist_path typo points at a non-existent location; first use after cloning a repo that doesn't ship indexes.","solutions":["Run the indexing step for the repo root first so the FAISS index is persisted","Verify Path(persist_path).exists() before searching","If the index was deleted unintentionally, re-index and then retry the search"],"exampleFix":"# before\nrepo = IndexRepo(persist_path=\".index/repo_a\", root_path=\"repo_a\")\nawait repo.search(query, filenames=[f])  # raises: index dir absent\n# after: index first (e.g. via Editor write flow that feeds IndexRepo), then\nfrom pathlib import Path\nassert Path(\".index/repo_a\").exists()\nawait repo.search(query, filenames=[f])","handlingStrategy":"validation","validationCode":"from pathlib import Path\nif not Path(repo.persist_path).exists():\n    raise SystemExit(f\"no index at {repo.persist_path}; run indexing first\")","typeGuard":null,"tryCatchPattern":"try:\n    res = await repo.search(query, filenames=files)\nexcept ValueError as e:\n    if \"not exists\" in str(e):\n        # trigger an indexing pass over repo.root_path, then retry\n        raise","preventionTips":["Treat index creation as a prerequisite step in any RAG pipeline","Check the persist directory exists before constructing search flows","Keep index dirs inside the workspace so they are reproducible"],"tags":["rag","index","faiss","state"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}