{"record":{"id":"b61ba0bf38152c92","repo":"oraios/serena","slug":"memory-name-not-found","errorCode":null,"errorMessage":"Memory {name} not found.","messagePattern":"Memory (.+?) not found\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/memories/memory_manager.py","lineNumber":397,"sourceCode":"        regex_multiline: bool = True,\n    ) -> str:\n        \"\"\"\n        Edit a memory by replacing content matching a pattern.\n\n        :param name: the memory name\n        :param needle: the string or regex to search for\n        :param repl: the replacement string\n        :param mode: \"literal\" or \"regex\"\n        :param allow_multiple_occurrences:\n        :param is_tool_context: whether the call originates from a tool invocation (affects write-access checks)\n        :param regex_multiline: whether to apply multi-line regex matching, enabling the flags re.DOTALL and re.MULTILINE\n        \"\"\"\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        if not memory_file_path.exists():\n            raise FileNotFoundError(f\"Memory {name} not found.\")\n        with open(memory_file_path, encoding=self._encoding) as f:\n            original_content = f.read()\n        replacer = ContentReplacer(mode=mode, allow_multiple_occurrences=allow_multiple_occurrences, regex_multiline=regex_multiline)\n        updated_content = replacer.replace(original_content, needle, repl)\n        with open(memory_file_path, \"w\", encoding=self._encoding) as f:\n            f.write(updated_content)\n        return f\"Memory {name} edited successfully.\"\n\n    def validate_referential_integrity(\n        self, include_unmarked: bool = True, include_fuzzy_matching: bool = True\n    ) -> ReferentialIntegrityReport:\n        \"\"\"\n        Validates referential integrity across this manager's memories.\n\n        Thin wrapper around :meth:`MemoryReferenceAnalyzer.validate_referential_integrity`;\n        see that method for the full description of behavior and parameters.\n        \"\"\"\n        return MemoryReferenceAnalyzer(self).validate_referential_integrity(","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/memories/memory_manager.py#L379-L415","documentation":"Raised by MemoryManager.edit_memory in src/serena/memories/memory_manager.py:397 when the memory file corresponding to the given name does not exist in the memories directory. Serena memories are stored as markdown files named after the sanitized memory name; editing requires the file to already exist (use save_memory/create to make a new one).","triggerScenarios":"Calling edit_memory (or the edit_memory tool) with a memory name that was never saved, a name that differs from the sanitized on-disk name, or one that was previously deleted or renamed.","commonSituations":"Agents referencing a memory from memory list output after manual deletion from the .serena/memories/ folder; typos or case mismatches in the memory name; calling edit before create in an automation script.","solutions":["Run list_memories() and use an exact memory name from the result, respecting sanitization rules","Create the memory first with save_memory(name, ...) before editing it","Check the .serena/memories/ directory manually to confirm the file still exists"],"exampleFix":"// before\nmanager.edit_memory('architectur', needle='old', repl='new', mode='literal', allow_multiple_occurrences=False, is_tool_context=True)\n// after\nif 'architecture' in manager.list_memories().get_full_list():\n    manager.edit_memory('architecture', needle='old', repl='new', mode='literal', allow_multiple_occurrences=False, is_tool_context=True)","handlingStrategy":"validation","validationCode":"if name not in manager.list_memories().get_full_list():\n    raise LookupError(f'Memory {name} does not exist; create it first')","typeGuard":null,"tryCatchPattern":"try:\n    manager.edit_memory(name, needle, repl, mode='literal', allow_multiple_occurrences=False, is_tool_context=True)\nexcept FileNotFoundError:\n    manager.save_memory(name, default_content, is_tool_context=True)","preventionTips":["Always list memories before editing","Create memories with save_memory before editing","Do not manually delete files from .serena/memories/","Use exact, unsanitized names from list_memories output"],"tags":["python","file-not-found","memory"],"backgroundTag":"file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}