{"record":{"id":"861f11f4d0cfdbb1","repo":"bytedance/deer-flow","slug":"failed-to-clear-memory-data","errorCode":null,"errorMessage":"Failed to clear memory data.","messagePattern":"Failed to clear memory data\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/memory.py","lineNumber":300,"sourceCode":"\n@router.delete(\n    \"/memory\",\n    response_model=MemoryResponse,\n    response_model_exclude_none=True,\n    summary=\"Clear All Memory Data\",\n    description=\"Delete all saved memory data and reset the memory structure to an empty state.\",\n)\nasync def clear_memory(http_request: Request) -> MemoryResponse:\n    \"\"\"Clear all persisted memory data.\"\"\"\n    manager = await asyncio.to_thread(get_memory_manager)\n    try:\n        memory_data = await asyncio.to_thread(manager.clear_memory, user_id=_resolve_memory_user_id(http_request))\n    except NotImplementedError:\n        raise _unsupported_501(manager, \"clear memory\") from None\n    except (MemoryConflictError, MemoryCorruptionError) as exc:\n        raise _map_memory_manager_error(exc) from exc\n    except OSError as exc:\n        raise HTTPException(status_code=500, detail=\"Failed to clear memory data.\") from exc\n\n    return MemoryResponse(**memory_data)\n\n\n@router.post(\n    \"/memory/facts\",\n    response_model=MemoryResponse,\n    response_model_exclude_none=True,\n    summary=\"Create Memory Fact\",\n    description=\"Create a single saved memory fact manually.\",\n)\nasync def create_memory_fact_endpoint(request: FactCreateRequest, http_request: Request) -> MemoryResponse:\n    \"\"\"Create a single fact manually.\"\"\"\n    manager = await asyncio.to_thread(get_memory_manager)\n    try:\n        memory_data, fact_id = await asyncio.to_thread(\n            manager.create_fact,\n            content=request.content,","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/memory.py#L282-L318","documentation":"500 raised when MemoryManager.clear_memory raises OSError — an I/O-level failure deleting or rewriting the memory persistence files for the resolved user. Manager-level logical failures have their own mappings (NotImplementedError->501, MemoryConflictError/MemoryCorruptionError->mapped); this catch is strictly for filesystem errors such as permission denied or IO errors during the clear.","triggerScenarios":"DELETE-like clear endpoint invoked when the memory store directory is not writable by the Gateway process; the memory file is held/locked by another process; disk-full during the rewrite; NFS/overlayfs returning EACCES or EIO on unlink.","commonSituations":"Container deployments with wrong volume ownership for the memory directory; multiple Gateway instances pointing at one memory path; storage backend transient failures; restrictive SELinux/AppArmor policies.","solutions":["Check Gateway logs for the OSError details (errno/path) chained to this 500","Fix ownership/permissions on the memory storage directory so the Gateway process can read, write, and delete files in it","Ensure only one Gateway process uses the memory path, or move to a backend that supports your concurrency model","Retry once after fixing permissions — clear is idempotent"],"exampleFix":"# shell: fix container volume ownership that caused EACCES\n# before: memory dir owned by root, Gateway runs as app-user -> 500\n# after\nchown -R app-user:app-user /data/memory && chmod u+rwX /data/memory\n# then retry POST /api/memory/clear","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { await clearMemory(); } catch (e) { if (e.status === 500) { notify('clear failed — check storage permissions; safe to retry'); await delay(1000); return clearMemory(); /* idempotent */ } throw e; }","preventionTips":["Verify the memory storage directory is writable by the Gateway process at deploy time","Run one Gateway per memory path to avoid OS-level file contention","Clear is idempotent — retry after fixing the underlying I/O problem"],"tags":["memory","filesystem","permissions","http-500"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}