{"record":{"id":"4eddcdd370fc08d7","repo":"bytedance/deer-flow","slug":"memory-data","errorCode":null,"errorMessage":"memory_data","messagePattern":"memory_data","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/updater.py","lineNumber":815,"sourceCode":"    ) -> bool:\n        \"\"\"Persist memory data via the injected storage.\"\"\"\n        kwargs: dict[str, Any] = {\"user_id\": user_id}\n        if expected_revision is not None:\n            kwargs[\"expected_revision\"] = expected_revision\n        return self._storage.save(memory_data, agent_name, **kwargs)\n\n    def get_memory_data(self, agent_name: str | None = None, *, user_id: str | None = None) -> dict[str, Any]:\n        \"\"\"Get the current memory data via the injected storage.\"\"\"\n        return self._storage.load(agent_name, user_id=user_id)\n\n    def reload_memory_data(self, agent_name: str | None = None, *, user_id: str | None = None) -> dict[str, Any]:\n        \"\"\"Reload memory data via the injected storage.\"\"\"\n        return self._storage.reload(agent_name, user_id=user_id)\n\n    def import_memory_data(self, memory_data: dict[str, Any], agent_name: str | None = None, *, user_id: str | None = None) -> dict[str, Any]:\n        \"\"\"Persist imported memory data via the injected storage.\"\"\"\n        if not isinstance(memory_data, dict):\n            raise ValueError(\"memory_data\")\n        memory_data = copy.deepcopy(memory_data)\n        empty = create_empty_memory()\n        for section in (\"user\", \"history\"):\n            incoming_section = memory_data.get(section, {})\n            if not isinstance(incoming_section, dict):\n                raise ValueError(f\"memory_data.{section}\")\n            complete_section = copy.deepcopy(empty[section])\n            for key, value in incoming_section.items():\n                if key in complete_section and isinstance(complete_section[key], dict) and isinstance(value, dict):\n                    complete_section[key].update(copy.deepcopy(value))\n                else:\n                    complete_section[key] = copy.deepcopy(value)\n            memory_data[section] = complete_section\n        if agent_name is not None and getattr(type(self._storage), \"apply_changes\", None) is not MemoryStorage.apply_changes:\n            current = self.get_memory_data(agent_name, user_id=user_id)\n            incoming_facts = copy.deepcopy(memory_data.get(\"facts\", []))\n            if not isinstance(incoming_facts, list) or any(not isinstance(fact, dict) for fact in incoming_facts):\n                raise ValueError(\"memory_data.facts\")","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/updater.py#L797-L833","documentation":"MemoryUpdater.import_memory_data() first checks that the incoming memory_data is a dict; anything else (list, string, null, number) raises this minimal ValueError. Import merges sections ('user', 'history') into an empty template and upserts facts, so a non-object root has no meaningful interpretation and is rejected before any deepcopy or storage write.","triggerScenarios":"import_memory_data(json.loads(raw)) where raw is a JSON array of facts or a bare string; passing a list of fact dicts directly; forwarding a request body that failed to be parsed into an object.","commonSituations":"Importing an exported memory file whose format changed between versions; a UI upload endpoint sending a JSON array; API clients wrapping memory in the wrong envelope.","solutions":["Wrap list payloads: import_memory_data({'facts': [...fact dicts...]}, agent_name=...).","Validate the parsed root type at the HTTP boundary (pydantic root model typed as dict).","Check for a version field in exported files before importing and convert old formats to the current object shape."],"exampleFix":"# before\nupdater.import_memory_data([fact1, fact2], agent_name=a)\n\n# after\nupdater.import_memory_data({\"facts\": [fact1, fact2], \"user\": {}, \"history\": {}}, agent_name=a)","handlingStrategy":"type-guard","validationCode":"if not isinstance(memory_data, dict):\n    if isinstance(memory_data, list):\n        memory_data = {\"facts\": memory_data}\n    else:\n        raise HTTPException(400, \"memory import payload must be a JSON object\")\nupdater.import_memory_data(memory_data, agent_name=agent_name)","typeGuard":"def is_memory_document(value: object) -> TypeGuard[dict[str, Any]]:\n    return isinstance(value, dict)","tryCatchPattern":null,"preventionTips":["Type the import endpoint's body as a dict/TypedDict via pydantic.","Version your export format and convert old formats before importing.","Wrap list-of-facts uploads in {'facts': [...]} explicitly."],"tags":["memory","validation","import","deermem"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}