{"record":{"id":"04763f1d7b348347","repo":"bytedance/deer-flow","slug":"memory-data-section","errorCode":null,"errorMessage":"memory_data.{section}","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":821,"sourceCode":"\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\")\n            for fact in incoming_facts:\n                fact[\"id\"] = str(fact.get(\"id\") or f\"fact_{uuid.uuid4().hex}\")\n                fact[\"confidence\"] = _coerce_source_confidence(fact)\n            current_by_id = {str(fact.get(\"id\")): fact for fact in current.get(\"facts\", []) if isinstance(fact, dict)}\n            incoming_ids = {str(fact.get(\"id\")) for fact in incoming_facts}\n            self._storage.apply_changes(","sourceCodeStart":803,"sourceCodeEnd":839,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/updater.py#L803-L839","documentation":"During import, each summaries section memory_data['user'] and memory_data['history'] must itself be a dict (missing keys default to {}). The f-string message names the offending section ('memory_data.user' or 'memory_data.history'). The check runs per section before merging into the empty template, so nothing is persisted when it fires.","triggerScenarios":"import_memory_data({'user': 'friendly assistant', ...}) where the section is a plain string; {'history': [...messages...]} as a list; JSON exports where these sections were flattened into arrays or strings.","commonSituations":"Older export formats storing history as a message list; hand-written import files; LLM-generated memory documents putting prose in 'user' instead of a structured profile dict.","solutions":["Make each section an object: {'user': {'name': ...}, 'history': {'summary': ...}}.","Convert legacy list-shaped history into the dict shape at import time (e.g. {'messages': [...]}) before calling import_memory_data.","Validate the upload with a pydantic model declaring user/history as dict fields."],"exampleFix":"# before\nupdater.import_memory_data({\"user\": \"likes tea\", \"history\": []}, agent_name=a)\n\n# after\nupdater.import_memory_data({\"user\": {\"preferences\": \"likes tea\"}, \"history\": {\"messages\": []}}, agent_name=a)","handlingStrategy":"type-guard","validationCode":"for section in (\"user\", \"history\"):\n    value = memory_data.get(section, {})\n    if not isinstance(value, dict):\n        raise HTTPException(400, f\"memory_data.{section} must be an object\")","typeGuard":"def has_valid_summary_sections(doc: object) -> TypeGuard[dict[str, Any]]:\n    return isinstance(doc, dict) and all(\n        isinstance(doc.get(section, {}), dict) for section in (\"user\", \"history\")\n    )","tryCatchPattern":null,"preventionTips":["Define 'user' and 'history' as object schemas in the import/export format docs.","Convert legacy list-shaped history sections at import time.","Validate uploads with a pydantic model declaring user/history as dict."],"tags":["memory","validation","import","deermem"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}