{"record":{"id":"ef089b432c4404af","repo":"oraios/serena","slug":"relative-path-relative-path-does-not-exist","errorCode":null,"errorMessage":"Relative path {relative_path} does not exist.","messagePattern":"Relative path (.+?) does not exist\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/project.py","lineNumber":400,"sourceCode":"            return rel_file_paths\n\n    def _create_file_collection(self, relative_path: str, *, code_files_only: bool, skip_ignored_files: bool) -> FileCollection:\n        \"\"\"\n        Creates the file collection for the given relative path.\n\n        :param relative_path: the relative path to create the file collection for, relative to the project root\n        :param code_files_only: whether to include only (non-ignored) code files\n        :param skip_ignored_files: whether to skip ignored files; has no effect if `code_files_only` is True\n        :return:\n        \"\"\"\n        if FileProxy.is_external_path(relative_path):\n            # single external path: create appropriate proxy\n            file_collection = FileCollection([FileProxy.from_project_relative_path(self, relative_path)])\n        else:\n            # path is a local project path\n            abs_path = os.path.join(self.project_root, relative_path)\n            if not os.path.exists(abs_path):\n                raise FileNotFoundError(f\"Relative path {relative_path} does not exist.\")\n\n            if code_files_only:\n                relative_file_paths = self.gather_source_files(relative_path=relative_path)\n                file_collection = FileCollection.from_local_project_paths(relative_file_paths, self)\n            else:\n                abs_path = os.path.join(self.project_root, relative_path)\n                if os.path.isfile(abs_path):\n                    rel_paths_to_search = [relative_path]\n                else:\n                    is_ignored_path_fn = self.get_is_ignored_path_fn(base_path=relative_path, skip_ignored_paths=skip_ignored_files)\n                    _dirs, rel_paths_to_search = scan_directory(\n                        path=abs_path,\n                        recursive=True,\n                        is_ignored_dir=is_ignored_path_fn,\n                        is_ignored_file=is_ignored_path_fn,\n                        relative_to=self.project_root,\n                    )\n                file_collection = FileCollection.from_local_project_paths(rel_paths_to_search, self)","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/project.py#L382-L418","documentation":"Raised by Project._create_file_collection (src/serena/project.py:400) when the local project-relative path passed to file collection (e.g. from search_project_files_for_pattern) does not exist under the project root. It guards creation of FileCollection objects over nonexistent local paths.","triggerScenarios":"Calling search_project_files_for_pattern with a path not on disk; race between listing and opening files that were deleted concurrently.","commonSituations":"Searching a stale subdirectory path after a rename; searching while a build/checkout mutates the tree; typos in the search path argument.","solutions":["Confirm the path exists under the project root before searching","Use a valid directory or '' for the whole project as the search scope","Re-run after the workspace settles if files are being concurrently modified"],"exampleFix":"// before\nresults = project.search_project_files_for_pattern('TODO', relative_path='src/removed')\n// after\nscope = 'src/removed' if os.path.exists(os.path.join(project.project_root, 'src/removed')) else ''\nresults = project.search_project_files_for_pattern('TODO', relative_path=scope)","handlingStrategy":"validation","validationCode":"scope = relative_path or ''\nif scope and not os.path.exists(os.path.join(project.project_root, scope)):\n    scope = ''","typeGuard":null,"tryCatchPattern":"try:\n    results = project.search_project_files_for_pattern(pattern, relative_path=relative_path)\nexcept FileNotFoundError:\n    results = project.search_project_files_for_pattern(pattern)","preventionTips":["Verify search scope paths exist before searching","Avoid searching while the tree is being mutated","Default to the project root when a subpath may not exist"],"tags":["python","file-not-found","search"],"backgroundTag":"file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}