{"record":{"id":"610fe624d4bb7766","repo":"FoundationAgents/OpenManus","slug":"no-such-file-or-directory-item-path-str","errorCode":null,"errorMessage":"No such file or directory: {item[path_str]}","messagePattern":"No such file or directory: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"app/tool/chart_visualization/data_visualization.py","lineNumber":79,"sourceCode":"        self,\n        json_info: list[dict[str, str]],\n        path_str: str,\n        directory: str = None,\n    ) -> list[str]:\n        res = []\n        for item in json_info:\n            if os.path.exists(item[path_str]):\n                res.append(item[path_str])\n            elif os.path.exists(\n                os.path.join(f\"{directory or config.workspace_root}\", item[path_str])\n            ):\n                res.append(\n                    os.path.join(\n                        f\"{directory or config.workspace_root}\", item[path_str]\n                    )\n                )\n            else:\n                raise Exception(f\"No such file or directory: {item[path_str]}\")\n        return res\n\n    def success_output_template(self, result: list[dict[str, str]]) -> str:\n        content = \"\"\n        if len(result) == 0:\n            return \"Is EMPTY!\"\n        for item in result:\n            content += f\"\"\"## {item['title']}\\nChart saved in: {item['chart_path']}\"\"\"\n            if \"insight_path\" in item and item[\"insight_path\"] and \"insight_md\" in item:\n                content += \"\\n\" + item[\"insight_md\"]\n            else:\n                content += \"\\n\"\n        return f\"Chart Generated Successful!\\n{content}\"\n\n    async def data_visualization(\n        self, json_info: list[dict[str, str]], output_type: str, language: str\n    ) -> str:\n        data_list = []","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/tool/chart_visualization/data_visualization.py#L61-L97","documentation":"The chart-visualization tool checks every path an LLM produced in its JSON plan: each item[path_str] must exist either as given or joined onto directory/config.workspace_root. If neither resolves, a bare Exception is raised with the missing path. Because the paths come from model output, the usual cause is a hallucinated or mis-joined relative path, not a filesystem fault.","triggerScenarios":"LLM outputs a path like './data/sales.csv' that only exists relative to some other base; the file was never generated by a preceding step; the directory parameter was omitted so workspace_root was used but the file lives elsewhere; case mismatch on case-sensitive filesystems.","commonSituations":"Multi-step agent pipelines where a data-generation step failed silently before charting; running the tool with the wrong directory argument; LLM inventing plausible-looking filenames.","solutions":["Verify the referenced data files exist before invoking the chart tool, and pass the directory they actually live in.","Re-prompt the LLM with the tool's error message plus an 'ls' of the directory so its next plan uses real paths.","Make upstream steps fail loudly (fail-fast on data generation) so the chart step never runs with missing inputs.","In code, replace this catch-all with ToolError and include both candidate paths (raw and joined) in the message for debuggability."],"exampleFix":"# before\nresult = await viz_tool.execute(command=\"...json from LLM...\", directory=None)\n\n# after\ndata_dir = config.workspace_root / \"data\"\nassert (data_dir / \"sales.csv\").exists(), \"sales.csv missing; regenerate it first\"\nresult = await viz_tool.execute(command=llm_json, directory=str(data_dir))","handlingStrategy":"validation","validationCode":"import os\nbase = directory or str(config.workspace_root)\nfor item in json_info:\n    p = item[path_str]\n    if not (os.path.exists(p) or os.path.exists(os.path.join(base, p))):\n        raise FileNotFoundError(f'{p} not found in cwd or {base}')","typeGuard":"def all_paths_resolvable(json_info: list[dict], base: str) -> bool:\n    return all(\n        os.path.exists(it[path_str]) or os.path.exists(os.path.join(base, it[path_str]))\n        for it in json_info\n    )","tryCatchPattern":"try:\n    result = await viz_tool.execute(command=llm_json, directory=base)\nexcept Exception as e:\n    if 'No such file or directory' in str(e):\n        listing = await shell.run(f'ls {base}')\n        llm_json = replan_with_listing(llm_json, listing)  # re-prompt with real files\n        result = await viz_tool.execute(command=llm_json, directory=base)\n    else:\n        raise","preventionTips":["Pass directory explicitly — don't rely on workspace_root defaults.","Fail fast on data-generation steps so charting never sees missing files.","Feed directory listings back to the LLM after path errors."],"tags":["llm","file-existence","chart","workspace"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}