{"record":{"id":"723f295fbf19664d","repo":"oraios/serena","slug":"path-relative-path-is-ignored","errorCode":null,"errorMessage":"Path {relative_path} is ignored","messagePattern":"Path (.+?) is ignored","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/project.py","lineNumber":345,"sourceCode":"\n    def validate_relative_path(self, relative_path: str, require_not_ignored: bool = False) -> None:\n        \"\"\"\n        Validates that the given relative path is within the project directory\n        (and, optionally, not ignored according to the project's ignore settings),\n        raising a ValueError if the validation fails.\n\n        :param relative_path: the path to validate, relative to the project root\n        :param require_not_ignored: if True, the path must not be ignored according to the project's ignore settings\n        \"\"\"\n        if FileProxy.is_external_path(relative_path):\n            return\n\n        if not self.is_path_in_project(relative_path):\n            raise ValueError(f\"{relative_path=} points outside the project root ({self.project_root})\")\n\n        if require_not_ignored:\n            if self.is_ignored_path(relative_path):\n                raise ValueError(f\"Path {relative_path} is ignored\")\n\n    def gather_source_files(self, relative_path: str = \"\") -> list[str]:\n        \"\"\"Retrieves relative paths of all source files, optionally limited to the given path\n\n        :param relative_path: if provided, restrict search to this path\n        \"\"\"\n        rel_file_paths = []\n        start_path = os.path.join(self.project_root, relative_path)\n        if not os.path.exists(start_path):\n            raise FileNotFoundError(f\"Relative path {start_path} not found.\")\n        if os.path.isfile(start_path):\n            return [relative_path]\n        else:\n            for root, dirs, files in os.walk(start_path, followlinks=True):\n                # prevent recursion into ignored directories\n                dirs[:] = [d for d in dirs if not self.is_ignored_path(os.path.join(root, d))]\n\n                # collect non-ignored files","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/project.py#L327-L363","documentation":"Raised by Project.validate_relative_path (src/serena/project.py:345) when require_not_ignored is true and the path matches the project's ignore rules (gitignore-style patterns or Serena ignore settings). The operation on that file is refused.","triggerScenarios":"Calling apply/validate_relative_path on a path under .git, node_modules, build outputs, or any pattern listed in the project's ignored patterns.","commonSituations":"Editing generated code or files inside ignored caches; new .gitignore rules added after the user started working with a file; explicit ignore config in .serena covering paths the agent needs.","solutions":["Choose a target file that is not ignored, or reference the non-ignored source file","Adjust the project's ignore configuration (.serena/ignore or .gitignore) to un-ignore the required path","Set require_not_ignored=False only if you consciously accept operating on ignored paths"],"exampleFix":"// before\nproject.validate_relative_path('build/out.py', require_not_ignored=True)  # build/ ignored\n// after\nproject.validate_relative_path('src/out.py', require_not_ignored=True)","handlingStrategy":"validation","validationCode":"if project.is_ignored_path(rel):\n    logging.warning('%s is ignored; pick another file or adjust ignore config', rel)","typeGuard":null,"tryCatchPattern":"try:\n    project.validate_relative_path(rel, require_not_ignored=True)\nexcept ValueError:\n    rel = pick_non_ignored_alternative(rel, project)","preventionTips":["Check is_ignored_path before operating on files","Review .serena and .gitignore rules when choosing targets","Avoid operating on build outputs and caches"],"tags":["python","ignore-spec","validation"],"backgroundTag":"path-ignored-by-gitignore","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}