{"record":{"id":"ee6e6149027eedbf","repo":"bytedance/deer-flow","slug":"journal-journal-path-contains-an-invalid-fact-id","errorCode":null,"errorMessage":"Journal {journal_path} contains an invalid fact id","messagePattern":"Journal (.+?) contains an invalid fact id","errorType":"exception","errorClass":"MemoryStorageCorruption","httpStatus":null,"severity":"error","filePath":"backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py","lineNumber":694,"sourceCode":"        except (OSError, json.JSONDecodeError, KeyError, TypeError) as exc:\n            raise MemoryStorageCorruption(f\"Invalid memory operation journal {journal_path}: {exc}\") from exc\n        recovery_dir = path.parent / \".recovery\" / operation_id\n        if state == \"prepared\":\n            backup_manifest = recovery_dir / \"memory.json\"\n            if backup_manifest.exists():\n                _atomic_write(path, backup_manifest.read_bytes())\n            elif int(journal.get(\"expectedRevision\") or 0) == 0:\n                path.unlink(missing_ok=True)\n            if isinstance(old_entries, dict):\n                old_ids = set(old_entries)\n                for fact_id in journal.get(\"factIds\", []):\n                    if fact_id not in old_ids:\n                        if agent_name is None:\n                            raise MemoryStorageCorruption(f\"Journal {journal_path} contains facts without agentName\")\n                        fact_file_path(path, str(fact_id), agent_name=agent_name).unlink(missing_ok=True)\n                for fact_id, entry in old_entries.items():\n                    if not isinstance(fact_id, str) or not fact_id or any(character not in \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\" for character in fact_id):\n                        raise MemoryStorageCorruption(f\"Journal {journal_path} contains an invalid fact id\")\n                    if not isinstance(entry, dict) or not isinstance(entry.get(\"path\"), str):\n                        continue\n                    backup = recovery_dir / f\"{fact_id}.md\"\n                    if backup.exists():\n                        _atomic_write(_safe_relative_path(path.parent, entry[\"path\"], label=\"journal\"), backup.read_bytes())\n        elif state != \"committed\":\n            raise MemoryStorageCorruption(f\"Unknown journal state {state!r} in {journal_path}\")\n        if recovery_dir.exists():\n            shutil.rmtree(recovery_dir)\n        journal_path.unlink(missing_ok=True)\n\n    def _commit_changes_locked(\n        self,\n        path: Path,\n        *,\n        user_id: str | None,\n        agent_name: str | None,\n        upserts: list[dict[str, Any]],","sourceCodeStart":676,"sourceCodeEnd":712,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py#L676-L712","documentation":"Error \"Journal {journal_path} contains an invalid fact id\" thrown in bytedance/deer-flow.","triggerScenarios":"Thrown at backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py:694 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove or repair the journal entry with the invalid fact id.","Delete the journal file to abandon the pending operation set."],"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"}