{"record":{"id":"4eac72fbfe768df0","repo":"oraios/serena","slug":"found-multiple-len-symbols-symbols-with-name-n","errorCode":null,"errorMessage":"Found multiple {len(symbols)} symbols with name {name_path} in file {relative_file_path}: {json.dumps(symbols, indent=2)}","messagePattern":"Found multiple (.+?) symbols with name (.+?) in file (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/code_editor.py","lineNumber":460,"sourceCode":"            self._content, _, _ = TextUtils.insert_text_at_position(self._content, pos.line, pos.col, text)\n\n    @contextmanager\n    def _open_file_context(self, relative_path: str) -> Iterator[\"CodeEditor.EditedFile\"]:\n        yield self.EditedFile(relative_path, self._project)\n\n    def _save_edited_file(self, edited_file: \"CodeEditor.EditedFile\") -> None:\n        super()._save_edited_file(edited_file)\n        with JetBrainsPluginClient.from_project(self._project) as client:\n            client.refresh_file(edited_file.relative_path)\n\n    def _find_unique_symbol(self, name_path: str, relative_file_path: str) -> JetBrainsSymbol:\n        with JetBrainsPluginClient.from_project(self._project) as client:\n            result = client.find_symbol(name_path, relative_path=relative_file_path, include_body=False, depth=0, include_location=True)\n            symbols = result[\"symbols\"]\n            if not symbols:\n                raise ValueError(f\"No symbol with name {name_path} found in file {relative_file_path}\")\n            if len(symbols) > 1:\n                raise ValueError(\n                    f\"Found multiple {len(symbols)} symbols with name {name_path} in file {relative_file_path}: \"\n                    + json.dumps(symbols, indent=2)\n                )\n            return JetBrainsSymbol(symbols[0], self._project)\n\n    def rename_symbol(\n        self,\n        name_path: str | None,\n        relative_path: str,\n        new_name: str,\n        rename_in_comments: bool = False,\n        rename_in_text_occurrences: bool = False,\n    ) -> str:\n        \"\"\"\n        Renames a code symbol, file, or directory throughout the codebase.\n\n        :param name_path: the name path of the symbol to rename. Set to None for renaming a file or directory.\n        :param relative_path: if `name_path` is passed, the relative path of the file containing the symbol.","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/code_editor.py#L442-L478","documentation":"When the JetBrains find_symbol query returns more than one symbol with the same name_path in the same file, _find_unique_symbol raises ValueError and includes all matches as JSON, because renaming requires an unambiguous target.","triggerScenarios":"rename_symbol on a name_path that matches multiple symbols in one file — e.g. overloaded methods, same-named nested symbols, or name_path segments that don't disambiguate scopes.","commonSituations":"Method overloads with identical names; shadowed names in nested scopes; languages where the same name can denote multiple entities in one file (getter/setter pairs, extensions).","solutions":["Extend name_path to a fully qualified path that uniquely identifies the symbol (e.g. 'Class.outer.inner')","Inspect the JSON list in the error message and pick the intended symbol's precise name_path","Rename at a unique definition location instead of by name lookup","Check for duplicate definitions accidentally introduced by copy-paste and remove one"],"exampleFix":"// before: ambiguous 'process' -> 3 matches\neditor.rename_symbol(\"process\", \"src/app.py\", \"process_data\")\n// after: disambiguated\neditor.rename_symbol(\"DataProcessor.process\", \"src/app.py\", \"process_data\")","handlingStrategy":"validation","validationCode":"result = client.find_symbol(name_path, relative_path=rel_path, include_location=True)\nif len(result[\"symbols\"]) != 1:\n    raise ValueError(\"name_path is ambiguous; qualify it further\")","typeGuard":null,"tryCatchPattern":"try:\n    editor.rename_symbol(name_path, rel_path, new_name)\nexcept ValueError as e:\n    if \"Found multiple\" in str(e):\n        matches = json.loads(str(e).split(\": \", 2)[-1])\n        name_path = choose_unique_name_path(matches)\n        editor.rename_symbol(name_path, rel_path, new_name)\n    else:\n        raise","preventionTips":["Always use fully qualified name_paths for nested/overloaded symbols","Read the JSON match list in the error to disambiguate","Avoid duplicate definitions from copy-paste"],"tags":["ambiguous-symbol","jetbrains","rename"],"backgroundTag":"ambiguous-symbol-name","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}