Skip to content

graph import --type edn of a :graph export drops task status history (:logseq.property.history/*) that the export contains #1420

Open
logseq/logseq
#13886

Description

@hdansou

Search first

  • I searched and no similar issues were found

Searched logseq/db-test and logseq/logseq (open and closed) for: property history, status history, import edn history, graph import, logseq.property.history, export edn property history. Related but not the same: #1120 ("enable property history" has no effect), #1389 (selected-block EDN round trip moves a target block), #1385 (partial EDN import and search).

What Happened?

logseq graph import --type edn of a full (:graph) export does not restore property history records (:logseq.property.history/*, the history of a task's status changes). The export file contains them. After the import they do not exist, so the restored graph has no status history. Nothing is reported: the CLI prints "Imported" and exits 0.

The same data round-trips with the :graph-human export, so the two exports disagree.

On a minimal graph with one task whose status changed twice: source graph 2 history records, :graph restore 0, :graph-human restore 2. On two real graphs the restore lost 22 and 39 history records. In those graphs I re-exported the restored graph and compared it with the original export (entity ids replaced by uuids): no other user data was lost.

Reproduce the Bug

Current stable desktop build, CLI only. <id> is the block id printed by the second command.

  1. Create a graph with a task whose status changes twice:
    logseq graph create --graph history-src
    logseq upsert block --graph history-src --target-page Repro --content "task one"
    logseq upsert block --graph history-src --id <id> --update-properties '{:logseq.property/status :logseq.property/status.todo}'
    logseq upsert block --graph history-src --id <id> --update-properties '{:logseq.property/status :logseq.property/status.doing}'
    logseq query --graph history-src --query '[:find (count ?h) . :where [?h :logseq.property.history/block]]'
    
    The query returns 2.
  2. Export it as a full graph and check that the file has the records:
    logseq graph export --graph history-src --type edn --file full.edn --edn-options '{:export-type :graph}' --pretty-print
    grep -c 'logseq.property.history' full.edn
    
    10 lines: 4 property definitions and 2 records with 3 datoms each (for example [194 :logseq.property.history/block 193]).
  3. Import it into a new graph and count again:
    logseq graph import --graph history-restored --type edn --input full.edn
    logseq query --graph history-restored --query '[:find (count ?h) . :where [?h :logseq.property.history/block]]'
    
    The query prints no count (null with --output json): no records. The import printed Imported edn from full.edn and the CLI exit code was 0. The block itself keeps its current status (:logseq.property/status.doing). Waiting 10 seconds changes nothing.
  4. For comparison, a human export restores them:
    logseq graph export --graph history-src --type edn --file human.edn --edn-options '{:export-type :graph-human}' --pretty-print
    logseq graph import --graph history-human --type edn --input human.edn
    
    The same query on history-human returns 2.

Expected Behavior

A :graph export restores everything it contains, including property history, as :graph-human does. The source describes :graph as "designed to be simple, reliable and for machines". If dropping history is intended, the import should say so (a warning or a count of skipped records) and not report plain success.

Screenshots

Files

Browser, Desktop or Mobile Platform Information

macOS 26.6.2 (arm64), Desktop app 2.0.2, logseq CLI 533ac43 (built 2026-10-07T14:07:14Z, upstream commit 533ac4382a, "fix(repeat): step Deadline and Scheduled in the local calendar (#13615)"). Reproduced against a CLI-owned worker.

Additional Context

Investigation (build 533ac43; code checked against master 4a5f1a253f, 2026-10-09)

  • Confirmed: the full export contains the history records (step 2), and the restored graph has none, immediately and 10 seconds after the import (step 3). They are never created, as opposed to being created and removed later.
  • Confirmed: the import code is unchanged on master. datoms-for-import and build-datom-import (deps/db/src/logseq/db/sqlite/export.cljs:1266-1283) are byte-identical in 533ac43 and 4a5f1a253f.
  • Where the CLI import goes: it calls :thread-api/import-edn (src/main/frontend/worker/handler/export.cljs:77-90), which builds build-datom-import (retract the current db, then [:db/add e a v] for every datom) and transacts with {::sqlite-export/imported-data? true}.
  • An upstream test expects this to work: import-graph-preserves-property-history (deps/db/test/logseq/db/sqlite/export_test.cljs:1200, added with b18056c910, 2026-02-25, "enhance: export-edn exports property history ... also ensure that it is idempotent"). It exports with graph-export-type, which is :graph unless LOGSEQ_EXPORT_HUMAN=1, imports, and asserts "Original property history datoms are imported". I did not run it.
  • Suspected, not confirmed: that test calls build-export and build-import on an in-memory db, while the CLI import goes through the worker (:thread-api/import-edn, which transacts with ldb/transact! and the worker transaction pipeline). So the records are probably lost in the worker's transaction path and not in build-import. I did not find the step that discards them: nothing in src/main/frontend/worker/pipeline.cljs removes :logseq.property.history/* entities, and validate-import-txs only drops datoms for "disallowed key" errors. I did not run the import under a debugger.
  • Round-trip method for the real graphs: export, import into a scratch graph, export again, then compare datoms with ids replaced by uuids, ignoring built-in entities, derived :block/refs and :block.temp/*. Result for both graphs: 0 datoms of user data lost, history records lost 22 and 39. The records are present in the original export file, which matches the live graph.

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)

Activity

  1. yuxi-liu-wired commented on Oct 27, 2026

    @yuxi-liu-wired

    Fixed in logseq/logseq#13886 (fix(import): EDN export and import keep pages, history, search and the target block). Its description has the cause and the test that pins it; it fails on current master and passes with the fix.

  2. added 5 commits that reference this issue on Oct 28, 2026
    4ccbba3
    a043384
    663c83c
    bdc285b
    de9150c
  3. added 8 commits that reference this issue on Nov 11, 2026
    f0c39d2
    c8145d9
    a402236
    131f587
    5798d29
    35ba931
    336bea0
    ceef900
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions