{"record":{"id":"61826d099b3ea0d3","repo":"oraios/serena","slug":"file-or-directory-relative-path-does-not-exist-i","errorCode":null,"errorMessage":"File or directory {relative_path} does not exist in the project.","messagePattern":"File or directory (.+?) does not exist in the project\\.","errorType":"validation","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/tools/symbol_tools.py","lineNumber":105,"sourceCode":"                return \"Depth 0 overview:\\n\" + self._to_json(compact_depth_0_result)\n\n            shortened_results = [make_depth_0_result, make_kind_counts]\n\n        return self._limit_length(result_json_str, max_answer_chars, shortened_result_factories=shortened_results)\n\n    def get_symbol_overview(self, relative_path: str, depth: int = 0) -> list[LanguageServerSymbol.OutputDict]:\n        \"\"\"\n        :param relative_path: relative path to a source file\n        :param depth: the depth up to which descendants shall be retrieved\n        :return: a list of symbol dictionaries representing the symbol overview of the file\n        \"\"\"\n        symbol_retriever = self.create_language_server_symbol_retriever()\n\n        # The symbol overview is capable of working with both files and directories,\n        # but we want to ensure that the user provides a file path.\n        file_path = os.path.join(self.project.project_root, relative_path)\n        if not os.path.exists(file_path):\n            raise FileNotFoundError(f\"File or directory {relative_path} does not exist in the project.\")\n        if os.path.isdir(file_path):\n            raise ValueError(f\"Expected a file path, but got a directory path: {relative_path}. \")\n        if not symbol_retriever.can_analyze_file(relative_path):\n            raise ValueError(\n                f\"Cannot extract symbols from file {relative_path}. Active language servers: {[l.value for l in self.agent.get_active_language_server_ids()]}\"\n            )\n\n        symbols = symbol_retriever.get_symbol_overview(relative_path)[relative_path]\n\n        def child_inclusion_predicate(s: LanguageServerSymbol) -> bool:\n            return not s.is_low_level()\n\n        symbol_dicts = []\n        for symbol in symbols:\n            symbol_dicts.append(\n                symbol.to_dict(\n                    name_path=False,\n                    name=True,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/tools/symbol_tools.py#L87-L123","documentation":"get_symbol_overview only accepts a path to an existing FILE (even though the underlying symbol retriever can handle directories, the tool deliberately forbids them). Before doing anything else it resolves the path against the project root and raises FileNotFoundError if nothing exists there.","triggerScenarios":"Calling get_symbol_overview with a relative_path that does not exist under project root — typo'd path, wrong casing, path outside the configured project, or the file was deleted/moved after the path string was built.","commonSituations":"Agent hallucinates a file name; user passes an absolute path where a project-relative path is expected; project root changed so a previously valid relative path no longer resolves.","solutions":["Verify the file exists relative to project root (os.path.exists(os.path.join(root, relative_path))) before calling","Convert absolute paths to project-relative paths (pathlib.Path(abs).relative_to(project_root))","List the project directory or use a file-listing tool to find the correct path"],"exampleFix":"// before\nget_symbol_overview.apply(relative_path='src/foo.py')  # file actually at serena/src/foo.py\n// FileNotFoundError\n\n// after\nrel = str(Path(abs_path).relative_to(project_root))\nassert (Path(project_root) / rel).exists()\nget_symbol_overview.apply(relative_path=rel)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nrel = str(Path(abs_path).resolve().relative_to(Path(project_root).resolve()))\nif not (Path(project_root) / rel).exists():\n    raise FileNotFoundError(rel)","typeGuard":"def path_exists_in_project(rel: str, root: str) -> bool:\n    return (Path(root) / rel).exists()","tryCatchPattern":"try:\n    overview = symbol_tool.get_symbol_overview(relative_path=rel)\nexcept FileNotFoundError:\n    rel = locate_file_with_file_tool(rel)  # search project for correct path\n    overview = symbol_tool.get_symbol_overview(relative_path=rel)","preventionTips":["Always use project-relative paths, never absolute ones","Verify file existence with a file-listing tool before symbol queries","Watch for typos and case sensitivity in paths"],"tags":["python","file-not-found","path","symbols"],"backgroundTag":"file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}