bytedance/deer-flow · error · HTTPException

Failed to import memory data.

Error message

Failed to import memory data.

What it means

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.

Source

Thrown at backend/app/gateway/routers/memory.py:430

    response_model_exclude_none=True,
    summary="Import Memory Data",
    description="Import and overwrite the current global memory data from a JSON payload.",
)
async def import_memory(request: MemoryResponse, http_request: Request) -> MemoryResponse:
    """Import and persist memory data."""
    manager = await asyncio.to_thread(get_memory_manager)
    try:
        memory_data = await asyncio.to_thread(
            manager.import_memory,
            request.model_dump(exclude_none=True),
            user_id=_resolve_memory_user_id(http_request),
        )
    except NotImplementedError:
        raise _unsupported_501(manager, "import memory") from None
    except (MemoryConflictError, MemoryCorruptionError) as exc:
        raise _map_memory_manager_error(exc) from exc
    except OSError as exc:
        raise HTTPException(status_code=500, detail="Failed to import memory data.") from exc

    return MemoryResponse(**memory_data)


@router.get(
    "/memory/config",
    response_model=MemoryConfigResponse,
    summary="Get Memory Configuration",
    description="Retrieve the current memory system configuration.",
)
async def get_memory_config_endpoint() -> MemoryConfigResponse:
    """Get the memory system configuration.

    Returns:
        The current memory configuration. The response is backend-agnostic:
        ``enabled`` / ``injection_enabled`` / ``mode`` are mechanism-level
        fields that apply to any backend (``mode`` selects middleware vs tool
        operation), and ``backend_config`` is an opaque dict the active

View on GitHub (pinned to 1dd6ba1acb)

Solutions

  1. Check Gateway logs for the underlying OSError to identify the path and errno.
  2. 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.
  3. If the store was left partially written, restore from the exported backup you are importing (or another export) before retrying.
Defensive patterns

Strategy: retry

Validate before calling

payload = json.load(open("memory_backup.json"))
required = {"facts"}  # keys produced by /memory/export
missing = required - payload.keys()
assert not missing, f"backup missing keys: {missing}"

Type guard

def is_valid_export(doc: dict) -> bool:
    return isinstance(doc, dict) and "facts" in doc and isinstance(doc["facts"], list)

Try / catch

resp = requests.post(f"{BASE}/api/memory/import", json=payload)
if resp.status_code == 500:
    # I/O failure mid-import: verify store health, then retry — import is a replace operation
    check_store_health_then_retry(payload)

Prevention

When it happens

Trigger: 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.

Common situations: Restoring a backup into a container whose data volume is read-only or full; importing concurrently with a large write from another request.

Related errors


AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14). Data as JSON: /api/errors/be8479fc118a8918. Report an issue: GitHub.