{"record":{"id":"be8479fc118a8918","repo":"bytedance/deer-flow","slug":"failed-to-import-memory-data","errorCode":null,"errorMessage":"Failed to import memory data.","messagePattern":"Failed to import memory data\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/memory.py","lineNumber":430,"sourceCode":"    response_model_exclude_none=True,\n    summary=\"Import Memory Data\",\n    description=\"Import and overwrite the current global memory data from a JSON payload.\",\n)\nasync def import_memory(request: MemoryResponse, http_request: Request) -> MemoryResponse:\n    \"\"\"Import and persist memory data.\"\"\"\n    manager = await asyncio.to_thread(get_memory_manager)\n    try:\n        memory_data = await asyncio.to_thread(\n            manager.import_memory,\n            request.model_dump(exclude_none=True),\n            user_id=_resolve_memory_user_id(http_request),\n        )\n    except NotImplementedError:\n        raise _unsupported_501(manager, \"import 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 import memory data.\") from exc\n\n    return MemoryResponse(**memory_data)\n\n\n@router.get(\n    \"/memory/config\",\n    response_model=MemoryConfigResponse,\n    summary=\"Get Memory Configuration\",\n    description=\"Retrieve the current memory system configuration.\",\n)\nasync def get_memory_config_endpoint() -> MemoryConfigResponse:\n    \"\"\"Get the memory system configuration.\n\n    Returns:\n        The current memory configuration. The response is backend-agnostic:\n        ``enabled`` / ``injection_enabled`` / ``mode`` are mechanism-level\n        fields that apply to any backend (``mode`` selects middleware vs tool\n        operation), and ``backend_config`` is an opaque dict the active","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/memory.py#L412-L448","documentation":"Raised as HTTP 500 by the memory import endpoint when manager.import_memory raises OSError — the imported payload was accepted but could not be persisted to the memory store. Validation and conflict/corruption failures are mapped to other statuses; this is purely an I/O write failure.","triggerScenarios":"POST /api/memory/import with a JSON body (typically from a prior /memory/export) while the store write fails: unwritable directory, full disk, or locked store file.","commonSituations":"Restoring a backup into a container whose data volume is read-only or full; importing concurrently with a large write from another request.","solutions":["Check Gateway logs for the underlying OSError to identify the path and errno.","Make the memory store writable and ensure free disk space, then retry the import — the endpoint replaces state, so a retry after a failed write is safe.","If the store was left partially written, restore from the exported backup you are importing (or another export) before retrying."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"payload = json.load(open(\"memory_backup.json\"))\nrequired = {\"facts\"}  # keys produced by /memory/export\nmissing = required - payload.keys()\nassert not missing, f\"backup missing keys: {missing}\"","typeGuard":"def is_valid_export(doc: dict) -> bool:\n    return isinstance(doc, dict) and \"facts\" in doc and isinstance(doc[\"facts\"], list)","tryCatchPattern":"resp = requests.post(f\"{BASE}/api/memory/import\", json=payload)\nif resp.status_code == 500:\n    # I/O failure mid-import: verify store health, then retry — import is a replace operation\n    check_store_health_then_retry(payload)","preventionTips":["Export before you import, so any failed import is recoverable.","Verify writability of the store before starting a large import.","Do not run import while heavy memory traffic is in flight."],"tags":["memory","import","filesystem","http-500"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}