{"record":{"id":"6ec9c7970db55258","repo":"oraios/serena","slug":"memory-named-name-not-found","errorCode":null,"errorMessage":"Memory named '{name}' not found","messagePattern":"Memory named '(.+?)' not found","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/memories/memory_manager.py","lineNumber":209,"sourceCode":"            # Strip \"global/\" prefix and resolve against global dir\n            sub_name = name[len(self.GLOBAL_TOPIC) + 1 :]\n            return self._resolve_memory_path(self._global_memory_dir, sub_name.split(\"/\"))\n\n        # Project-local memory\n        assert self._project_memory_dir is not None, \"Project dir was not passed at initialization\"\n        return self._resolve_memory_path(self._project_memory_dir, parts)\n\n    def _check_write_access(self, name: str, is_tool_context: bool) -> None:\n        # in tool context, memories can be read-only\n        if is_tool_context and self._is_read_only_memory(name):\n            raise PermissionError(f\"Attempted to write to read_only memory: '{name}')\")\n\n    def load_memory(self, name: str) -> str:\n        name = self._sanitize_name(name)\n        self._check_not_ignored(name)\n        memory_file_path = self.get_memory_file_path(name)\n        if not memory_file_path.exists():\n            raise FileNotFoundError(f\"Memory named '{name}' not found\")\n        with open(memory_file_path, encoding=self._encoding) as f:\n            return f.read()\n\n    def save_memory(self, name: str, content: str, is_tool_context: bool) -> str:\n        name = self._sanitize_name(name)\n        self._check_not_ignored(name)\n        self._check_write_access(name, is_tool_context)\n        memory_file_path = self.get_memory_file_path(name)\n        with open(memory_file_path, \"w\", encoding=self._encoding) as f:\n            f.write(content)\n        return f\"Memory {name} written.\"\n\n    class MemoriesList:\n        def __init__(self) -> None:\n            self.memories: list[str] = []\n            self.read_only_memories: list[str] = []\n\n        def __len__(self) -> int:","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/memories/memory_manager.py#L191-L227","documentation":"load_memory raises FileNotFoundError when no memory file exists at the resolved path for the given (sanitized) name. The name passed validation, but there is simply no such memory in the project or global memories directory.","triggerScenarios":"Calling load_memory with a name that was never created via save_memory, was deleted, was renamed/moved elsewhere, or is subtly misspelled ('-' vs '_', missing topic prefix, wrong global/ path).","commonSituations":"Agents guessing memory names from project descriptions; referencing a memory after rename_memory_and_propagate_references changed its name; switching projects where the memory only exists globally (or vice versa); stale prompts referencing deleted memories.","solutions":["List available memories first (list_memories) and use an exact existing name.","Check the name's spelling and structure: no '.md' suffix needed (it is stripped), use 'global/<name>' for global memories.","Create the memory with save_memory if it should exist.","If it was renamed, use the new name (rename tools update references in other memories)."],"exampleFix":"// before\ncontent = manager.load_memory(\"coding_convention\")  # typo\n// after\nnames = manager.list_memories()\ncontent = manager.load_memory(\"coding_conventions\")  # exact match from list","handlingStrategy":"try-catch","validationCode":"names = manager.list_memories()\nif name not in names:\n    raise KeyError(f\"memory {name!r} not found; available: {names}\")","typeGuard":"def memory_exists(manager, name: str) -> bool:\n    return manager.get_memory_file_path(name).exists()","tryCatchPattern":"try:\n    content = manager.load_memory(name)\nexcept FileNotFoundError:\n    log.warning(\"memory %r missing; creating empty\", name)\n    manager.save_memory(name, \"\", is_tool_context=False)\n    content = \"\"","preventionTips":["Always list_memories and pick exact names before reading","Remember _sanitize_name strips 'mem:' and '.md'; don't double-apply them","Update prompts/references after renames so stale names aren't reused"],"tags":["python","memory","not-found","naming"],"backgroundTag":"memory-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}