bytedance/deer-flow · error · MemoryStorageCorruption

Journal contains an invalid fact id

Error message

Journal {journal_path} contains an invalid fact id

What it means

Error "Journal {journal_path} contains an invalid fact id" thrown in bytedance/deer-flow.

Solutions

  1. Remove or repair the journal entry with the invalid fact id.
  2. Delete the journal file to abandon the pending operation set.

When it happens

Trigger: Thrown at backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py:694 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py:694

        except (OSError, json.JSONDecodeError, KeyError, TypeError) as exc:
            raise MemoryStorageCorruption(f"Invalid memory operation journal {journal_path}: {exc}") from exc
        recovery_dir = path.parent / ".recovery" / operation_id
        if state == "prepared":
            backup_manifest = recovery_dir / "memory.json"
            if backup_manifest.exists():
                _atomic_write(path, backup_manifest.read_bytes())
            elif int(journal.get("expectedRevision") or 0) == 0:
                path.unlink(missing_ok=True)
            if isinstance(old_entries, dict):
                old_ids = set(old_entries)
                for fact_id in journal.get("factIds", []):
                    if fact_id not in old_ids:
                        if agent_name is None:
                            raise MemoryStorageCorruption(f"Journal {journal_path} contains facts without agentName")
                        fact_file_path(path, str(fact_id), agent_name=agent_name).unlink(missing_ok=True)
                for fact_id, entry in old_entries.items():
                    if not isinstance(fact_id, str) or not fact_id or any(character not in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" for character in fact_id):
                        raise MemoryStorageCorruption(f"Journal {journal_path} contains an invalid fact id")
                    if not isinstance(entry, dict) or not isinstance(entry.get("path"), str):
                        continue
                    backup = recovery_dir / f"{fact_id}.md"
                    if backup.exists():
                        _atomic_write(_safe_relative_path(path.parent, entry["path"], label="journal"), backup.read_bytes())
        elif state != "committed":
            raise MemoryStorageCorruption(f"Unknown journal state {state!r} in {journal_path}")
        if recovery_dir.exists():
            shutil.rmtree(recovery_dir)
        journal_path.unlink(missing_ok=True)

    def _commit_changes_locked(
        self,
        path: Path,
        *,
        user_id: str | None,
        agent_name: str | None,
        upserts: list[dict[str, Any]],

View on GitHub (pinned to 1dd6ba1acb)