{"record":{"id":"ddc2688ec7b67ccd","repo":"FoundationAgents/MetaGPT","slug":"file-data-path-not-found","errorCode":null,"errorMessage":"File {data_path} not found.","messagePattern":"File (.+?) not found\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"metagpt/document.py","lineNumber":125,"sourceCode":"        \"\"\"\n        return self.to_path()\n\n\nclass IndexableDocument(Document):\n    \"\"\"\n    Advanced document handling: For vector databases or search engines.\n    \"\"\"\n\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n\n    data: Union[pd.DataFrame, list]\n    content_col: Optional[str] = Field(default=\"\")\n    meta_col: Optional[str] = Field(default=\"\")\n\n    @classmethod\n    def from_path(cls, data_path: Path, content_col=\"content\", meta_col=\"metadata\"):\n        if not data_path.exists():\n            raise FileNotFoundError(f\"File {data_path} not found.\")\n        data = read_data(data_path)\n        if isinstance(data, pd.DataFrame):\n            validate_cols(content_col, data)\n            return cls(data=data, content=str(data), content_col=content_col, meta_col=meta_col)\n        try:\n            content = data_path.read_text()\n        except Exception as e:\n            logger.debug(f\"Load {str(data_path)} error: {e}\")\n            content = \"\"\n        return cls(data=data, content=content, content_col=content_col, meta_col=meta_col)\n\n    def _get_docs_and_metadatas_by_df(self) -> (list, list):\n        df = self.data\n        docs = []\n        metadatas = []\n        for i in tqdm(range(len(df))):\n            docs.append(df[self.content_col].iloc[i])\n            if self.meta_col:","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/document.py#L107-L143","documentation":"IndexableDocument.from_path first verifies the data file exists; a missing data_path raises FileNotFoundError echoing the path. This is the entry guard for the RAG indexing pipeline before read_data() attempts format-specific loading.","triggerScenarios":"IndexableDocument.from_path(Path('knowledge/base.xlsx')) where the directory or file does not exist; relative paths resolved from a different cwd; typo in the filename; mount/volume not attached in containers.","commonSituations":"Docker deployments where the data volume is not mounted at the expected path; notebooks run from a different working directory; data files moved or renamed after the indexing script was written.","solutions":["Resolve to an absolute path and assert existence before indexing.","Verify mounts/volumes and cwd in containerized runs.","Create or re-download the data file at the expected location."],"exampleFix":"# before\ndoc = IndexableDocument.from_path(Path('data/faq.csv'))  # FileNotFoundError\n\n# after\np = Path('data/faq.csv').resolve()\nassert p.is_file(), f'data file missing: {p}'\ndoc = IndexableDocument.from_path(p)","handlingStrategy":"validation","validationCode":"p = data_path.resolve()\nif not p.is_file():\n    raise FileNotFoundError(f'data file missing: {p}')\ndoc = IndexableDocument.from_path(p, content_col=content_col)","typeGuard":"def is_existing_file(p: Path) -> TypeGuard[Path]:\n    return p.exists() and p.is_file()","tryCatchPattern":null,"preventionTips":["Verify data volumes/mounts in containerized runs.","Use absolute paths for data files in indexing scripts.","Add a preflight existence check over the full file list before batch indexing."],"tags":["file-not-found","rag","path","document"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}