{"record":{"id":"a62f3e6c445e403a","repo":"oraios/serena","slug":"memory-old-name-not-found","errorCode":null,"errorMessage":"Memory {old_name} not found.","messagePattern":"Memory (.+?) not found\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/memories/memory_manager.py","lineNumber":337,"sourceCode":"        memory_file_path.unlink()\n        return f\"Memory {name} deleted.\"\n\n    def move_memory(self, old_name: str, new_name: str, is_tool_context: bool) -> str:\n        \"\"\"\n        Rename or move a memory file.\n        Moving between global and project scope (e.g. \"global/foo\" -> \"bar\") is supported.\n        \"\"\"\n        old_name = self._sanitize_name(old_name)\n        new_name = self._sanitize_name(new_name)\n        self._check_not_ignored(old_name)\n        self._check_not_ignored(new_name)\n        self._check_write_access(new_name, is_tool_context)\n\n        old_path = self.get_memory_file_path(old_name)\n        new_path = self.get_memory_file_path(new_name)\n\n        if not old_path.exists():\n            raise FileNotFoundError(f\"Memory {old_name} not found.\")\n        if new_path.exists():\n            raise FileExistsError(f\"Memory {new_name} already exists.\")\n\n        new_path.parent.mkdir(parents=True, exist_ok=True)\n        shutil.move(old_path, new_path)\n\n        return f\"Memory renamed from {old_name} to {new_name}.\"\n\n    def rename_memory_and_propagate_references(self, old_name: str, new_name: str, is_tool_context: bool) -> tuple[str, int]:\n        \"\"\"\n        Renames a memory and updates every ``mem:OLD_NAME`` reference across all memories.\n\n        Memories whose content does not contain a reference to ``old_name`` are left\n        untouched (no spurious mtime changes). Memories that do are rewritten via\n        :meth:`save_memory`.\n\n        :param old_name: the current memory name (the source of the rename)\n        :param new_name: the target memory name","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/memories/memory_manager.py#L319-L355","documentation":"move_memory (rename) raises FileNotFoundError when the source memory file old_name does not exist. The move/rename cannot proceed because there is nothing to move; note write-access checks for both names run first.","triggerScenarios":"Calling move_memory(old_name, new_name, is_tool_context) where old_name was never created, was deleted, or is misspelled; also when old_name refers to a memory in the wrong scope (project vs global/<name>).","commonSituations":"Renaming after the memory was already renamed (double rename); agents hallucinating the source memory name; renaming a global memory without the 'global/' prefix (it exists only under the global dir).","solutions":["Verify the source exists via list_memories (or get_memory_file_path(...).exists()) before renaming.","Use the exact current name including the 'global/' prefix for global memories.","If it was already renamed, use the current name as old_name or treat the operation as complete.","Recreate the source with save_memory if it was accidentally deleted and must be moved."],"exampleFix":"// before\nmanager.move_memory(\"old_notes\", \"new_notes\", is_tool_context=True)  # FileNotFoundError\n// after\nif manager.get_memory_file_path(\"old_notes\").exists():\n    manager.move_memory(\"old_notes\", \"new_notes\", is_tool_context=True)","handlingStrategy":"validation","validationCode":"if not manager.get_memory_file_path(old_name).exists():\n    raise KeyError(f\"cannot rename: source {old_name!r} does not exist\")","typeGuard":"def can_move(manager, old: str, new: str) -> bool:\n    return manager.get_memory_file_path(old).exists() and not manager.get_memory_file_path(new).exists()","tryCatchPattern":"try:\n    manager.move_memory(old_name, new_name, is_tool_context)\nexcept FileNotFoundError:\n    log.warning(\"source %r gone; skipping rename\", old_name)","preventionTips":["Check source existence before every move/rename","Use the correct scope prefix ('global/') for global memories","Avoid double renames by tracking the current name after each operation"],"tags":["python","memory","not-found","rename"],"backgroundTag":"memory-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}