{"record":{"id":"c58d4a7b6b6d3af4","repo":"bytedance/deer-flow","slug":"invalid-canonical-fact-fact-path-exc","errorCode":null,"errorMessage":"Invalid canonical fact {fact_path}: {exc}","messagePattern":"Invalid canonical fact (.+?): (.+?)","errorType":"exception","errorClass":"MemoryStorageCorruption","httpStatus":null,"severity":"error","filePath":"backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py","lineNumber":500,"sourceCode":"    @staticmethod\n    def _validate_loaded_fact(\n        fact: dict[str, Any],\n        fact_path: Path,\n        *,\n        user_id: str | None,\n        agent_name: str,\n    ) -> dict[str, Any]:\n        if str(fact.get(\"id\")) != fact_path.stem:\n            raise MemoryStorageCorruption(f\"Fact id mismatch for {fact_path}\")\n        expected_scope = _scope_dict(user_id, agent_name)\n        actual_scope = fact.get(\"scope\")\n        scope_matches = isinstance(actual_scope, dict) and actual_scope.get(\"userId\") == user_id and isinstance(actual_scope.get(\"agentName\"), str) and actual_scope[\"agentName\"].lower() == agent_name.lower()\n        if not scope_matches:\n            raise MemoryStorageCorruption(f\"Fact scope mismatch for {fact_path}: expected {expected_scope!r}, found {fact.get('scope')!r}\")\n        try:\n            return _normalize_fact(fact, scope=copy.deepcopy(actual_scope))\n        except ValueError as exc:\n            raise MemoryStorageCorruption(f\"Invalid canonical fact {fact_path}: {exc}\") from exc\n\n    def _load_agent_facts(self, path: Path, agent_name: str | None, *, user_id: str | None) -> list[dict[str, Any]]:\n        if agent_name is None:\n            return []\n        facts: list[dict[str, Any]] = []\n        for fact_path in sorted(agent_facts_directory(path, agent_name).glob(\"**/*.md\")):\n            fact = _parse_fact_markdown(fact_path)\n            facts.append(self._validate_loaded_fact(fact, fact_path, user_id=user_id, agent_name=agent_name))\n        # Shard directories are an internal layout detail and must not change\n        # the stable fact order observed by callers.\n        return sorted(facts, key=lambda fact: str(fact[\"id\"]))\n\n    def _read_fact(self, path: Path, fact_id: str, *, user_id: str | None, agent_name: str) -> tuple[dict[str, Any] | None, Path]:\n        fact_path = fact_file_path(path, fact_id, agent_name=agent_name)\n        if not fact_path.exists():\n            return None, fact_path\n        fact = _parse_fact_markdown(fact_path)\n        return self._validate_loaded_fact(fact, fact_path, user_id=user_id, agent_name=agent_name), fact_path","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py#L482-L518","documentation":"Error \"Invalid canonical fact {fact_path}: {exc}\" thrown in bytedance/deer-flow.","triggerScenarios":"Thrown at backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py:500 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the validation issue named in the exception (field type or value) in the fact file.","Delete the invalid fact file and recreate the fact via the memory API."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}