{"record":{"id":"8875193b8fc1e9ee","repo":"headroomlabs-ai/headroom","slug":"failed-to-update-memory-e","errorCode":null,"errorMessage":"Failed to update memory: {e}","messagePattern":"Failed to update memory: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"headroom/memory/backends/direct_mem0.py","lineNumber":884,"sourceCode":"        Args:\n            memory_id: ID of the memory to update.\n            new_content: New content to replace existing.\n            reason: Reason for the update.\n            user_id: User ID for validation.\n\n        Returns:\n            Updated Memory object.\n        \"\"\"\n        await self._ensure_initialized()\n\n        try:\n            await asyncio.to_thread(\n                self._mem0_client.update,\n                memory_id=memory_id,\n                data=new_content,\n            )\n        except Exception as e:\n            raise ValueError(f\"Failed to update memory: {e}\") from e\n\n        return Memory(\n            id=memory_id,\n            content=new_content,\n            user_id=user_id or \"\",\n            importance=0.5,\n            created_at=_utcnow(),\n            valid_from=_utcnow(),\n            metadata={\"update_reason\": reason} if reason else {},\n        )\n\n    async def delete_memory(\n        self,\n        memory_id: str,\n        reason: str | None = None,\n        user_id: str | None = None,\n    ) -> bool:\n        \"\"\"Delete a memory.","sourceCodeStart":866,"sourceCodeEnd":902,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/memory/backends/direct_mem0.py#L866-L902","documentation":"A ValueError raised by DirectMem0Adapter.update_memory() when the underlying self._mem0_client.update(...) call (run via asyncio.to_thread) throws for any reason. The original exception is chained ('from e') but its message is embedded into this generic wrapper, so the root cause (bad memory id, connectivity, mem0 API change) must be read from the inner text.","triggerScenarios":"Calling update_memory(memory_id, new_content) where memory_id does not exist in the mem0/Qdrant store, Qdrant or the mem0 backend is unreachable, or the installed mem0 version renamed the 'update' kwargs.","commonSituations":"Stale memory_id kept after a store wipe or collection re-creation; Qdrant container down; mem0 upgraded to a version with an incompatible client API.","solutions":["Read the '{e}' suffix of the message — it carries the real mem0 error and dictates the fix","Verify the memory id exists first (search/get by id) before updating","Check Qdrant/Neo4j service health (docker compose ps) if the inner error is a connection failure","Pin compatible versions: reinstall 'headroom-ai[memory-stack]' so mem0 matches what the adapter expects"],"exampleFix":"# before\nawait adapter.update_memory('bad-id', 'new text')  # ValueError: Failed to update memory: ...\n\n# after\nmem = await adapter.get_memory('bad-id')  # confirm existence / get valid id\nif mem:\n    await adapter.update_memory(mem.id, 'new text')","handlingStrategy":"try-catch","validationCode":"# confirm the target exists before updating\nfound = await adapter.get_memory(memory_id) if hasattr(adapter, 'get_memory') else None\nif found is None:\n    # avoid the wrapped failure: nothing to update\n    raise KeyError(memory_id)","typeGuard":null,"tryCatchPattern":"try:\n    updated = await adapter.update_memory(memory_id, new_content)\nexcept ValueError as e:\n    # inner mem0 error is embedded in the message\n    logger.error('update failed for %s: %s', memory_id, e)\n    if 'not found' in str(e):\n        await adapter.save(new_content, user_id=user_id)  # recreate path\n    else:\n        raise","preventionTips":["Always log the embedded '{e}' text — it identifies the true mem0 failure","Keep memory ids from the same session that created them","Health-check Qdrant before batch update jobs"],"tags":["python","mem0","update","valueerror","runtime-wrap","memory-backend"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}