logseq / logseq/db-test

EDN Import Error when importing tag that was already created by page import

Open
#958 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
28
Forks
2
PR merge metrics
No merged PRs in 30d

Description

### Search first

- [x] I searched and no similar issues were found

### What Happened?

I tried to import a page with tags and then the base tag. I get an error:

Invalid data writing to db!

### Reproduce the Bug

0. Create new graph for a clean base
1. import page with tags and properties using "Import EDN data" command

```
{:pages-and-blocks
[{:page
{:build/tags #{:user.class/Grnspechte-kAb3rnMZ},
:build/properties
{:user.property/Gre-kWkFTZ_D 122,
:user.property/Bedroht-X7sIvDOk true,
:user.property/Farbe-Dcnb6mnk "Rot"},
:block/title "Günther Grünspecht"},
:blocks
[{:block/title "Er ist ein bunter Vogel. Sagt man auch."}
{:block/title ""}]}],
:properties
{:user.property/Gre-kWkFTZ_D
{:db/cardinality :db.cardinality/one,
:logseq.property/type :number,
:block/title "Größe"},
:user.property/Bedroht-X7sIvDOk
{:db/cardinality :db.cardinality/one,
:logseq.property/type :checkbox,
:block/title "Bedroht"},
:user.property/Farbe-Dcnb6mnk
{:db/cardinality :db.cardinality/one,
:logseq.property/type :default,
:block/title "Farbe"}},
:classes
{:user.class/Grnspechte-kAb3rnMZ
{:block/title "Grünspechte",
:block/collapsed? false,
:build/class-extends #{:user.class/Vgel-Q0C0b7jy}},
:user.class/Vgel-Q0C0b7jy
{:block/title "Vögel",
:block/collapsed? false,
:build/class-properties
[:user.property/Gre-kWkFTZ_D
:user.property/Farbe-Dcnb6mnk
:user.property/Bedroht-X7sIvDOk]}},
:logseq.db.sqlite.export/export-type :page}
```

2. import base tag

```
{:pages-and-blocks
[{:page {:block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c"},
:blocks [{:block/title ""}]}],
:properties
{:user.property/Gre-kWkFTZ_D
{:db/cardinality :db.cardinality/one,
:logseq.property/type :number,
:block/title "Größe"},
:user.property/Farbe-Dcnb6mnk
{:db/cardinality :db.cardinality/one,
:logseq.property/type :default,
:block/title "Farbe"},
:user.property/Bedroht-X7sIvDOk
{:db/cardinality :db.cardinality/one,
:logseq.property/type :checkbox,
:block/title "Bedroht"}},
:classes
{:user.class/Vgel-Q0C0b7jy
{:block/title "Vögel",
:block/collapsed? false,
:block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c",
:build/keep-uuid? true,
:build/class-properties
[:user.property/Gre-kWkFTZ_D
:user.property/Farbe-Dcnb6mnk
:user.property/Bedroht-X7sIvDOk]}},
:logseq.db.sqlite.export/export-type :page}
```

### Expected Behavior

I should be able to import data that exist without conflict in one database into another, even one item at a time.

### Screenshots

_No response_

### Files

Terminal output:

```
:debug :db-gc There's no garbage data that's need to be collected.
"Invalid datascript entities detected amongst changed entity ids:" (206 199 207) :tx-meta {:outliner-op :batch-import-edn, :db-sync/tx-id #uuid "0ca176ff-dee0-45dc-b907-8a2cb5955813", :client-id "4d86d058-192d-4af8-ac0f-74f053a54654", :local-tx? true, :outliner-ops (), :logseq.db.sqlite.export/imported-data? true}
{:entity-map
{:block/tx-id 536870927,
:block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c",
:block/properties ([:logseq.property/created-by-ref 194]),
:db/id 206},
:errors
[{:block/title
{"normal-block" ["missing required key"],
"whiteboard-block" ["missing required key"]},
:block/parent
{"normal-block" ["missing required key"],
"whiteboard-block" ["missing required key"]},
:block/order {"normal-block" ["missing required key"]},
:block/page
{"normal-block" ["missing required key"],
"whiteboard-block" ["missing required key"]},
:block/created-at
{"normal-block" ["missing required key"],
"whiteboard-block" ["missing required key"]},
:block/updated-at
{"normal-block" ["missing required key"],
"whiteboard-block" ["missing required key"]}}]}

:debug :invalid-data {:tx-meta {:outliner-op :batch-import-edn, :db-sync/tx-id #uuid "0ca176ff-dee0-45dc-b907-8a2cb5955813", :client-id "4d86d058-192d-4af8-ac0f-74f053a54654", :local-tx? true, :outliner-ops (), :logseq.db.sqlite.export/imported-data? true}, :tx-data (#datascript/Datom [206 :block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c" 536870927 true] #datascript/Datom [199 :block/updated-at 1782150519240 536870927 false] #datascript/Datom [199 :block/updated-at 1782150608273 536870927 true] #datascript/Datom [199 :block/created-at 1782150519240 536870927 false] #datascript/Datom [199 :block/created-at 1782150608273 536870927 true] #datascript/Datom [207 :block/page 206 536870927 true] #datascript/Datom [207 :block/order "b1c" 536870927 true] #datascript/Datom [207 :block/parent 206 536870927 true] #datascript/Datom [207 :block/updated-at 1782150608273 536870927 true] #datascript/Datom [207 :block/created-at 1782150608273 536870927 true] #datascript/Datom [207 :block/title "" 536870927 true] #datascript/Datom [207 :block/uuid #uuid "15c75b6a-c926-4c30-be6c-1aa53f5e48ee" 536870927 true]), :errors [{:entity-map {:block/tx-id 536870927, :block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c", :block/properties ([:logseq.property/created-by-ref 194]), :db/id 206}, :errors [{:block/title {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/parent {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/order {"normal-block" ["missing required key"]}, :block/page {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/created-at {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/updated-at {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}}]}], :pipeline-tx-data ([206 :block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c" 536870927] [199 :block/updated-at 1782150519240 536870927] [199 :block/updated-at 1782150608273 536870927] [199 :block/created-at 1782150519240 536870927] [199 :block/created-at 1782150608273 536870927] [207 :block/page 206 536870927] [207 :block/order "b1c" 536870927] [207 :block/parent 206 536870927] [207 :block/updated-at 1782150608273 536870927] [207 :block/created-at 1782150608273 536870927] [207 :block/title "" 536870927] [207 :block/uuid #uuid "15c75b6a-c926-4c30-be6c-1aa53f5e48ee" 536870927] [206 :logseq.property/created-by-ref 194 536870928] [207 :logseq.property/created-by-ref 194 536870928] [206 :block/tx-id 536870927 536870929] [199 :block/tx-id 536870922 536870929] [199 :block/tx-id 536870927 536870929] [207 :block/tx-id 536870927 536870929])}
:debug :errors [{:entity-map {:block/tx-id 536870927, :block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c", :block/properties ([:logseq.property/created-by-ref 194]), :db/id 206}, :errors [{:block/title {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/parent {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/order {"normal-block" ["missing required key"]}, :block/page {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/created-at {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}, :block/updated-at {"normal-block" ["missing required key"], "whiteboard-block" ["missing required key"]}}]}]
:debug :transact-failed :tx-meta {:outliner-op :batch-import-edn, :db-sync/tx-id #uuid "0ca176ff-dee0-45dc-b907-8a2cb5955813", :client-id "4d86d058-192d-4af8-ac0f-74f053a54654", :local-tx? true, :outliner-ops (), :logseq.db.sqlite.export/imported-data? true} :tx-data (#datascript/Datom [206 :block/uuid #uuid "6a396945-247c-4223-9246-c17832e6032c" 536870927 true] #datascript/Datom [199 :block/updated-at 1782150519240 536870927 false] #datascript/Datom [199 :block/updated-at 1782150608273 536870927 true] #datascript/Datom [199 :block/created-at 1782150519240 536870927 false] #datascript/Datom [199 :block/created-at 1782150608273 536870927 true] #datascript/Datom [207 :block/page 206 536870927 true] #datascript/Datom [207 :block/order "b1c" 536870927 true] #datascript/Datom [207 :block/parent 206 536870927 true] #datascript/Datom [207 :block/updated-at 1782150608273 536870927 true] #datascript/Datom [207 :block/created-at 1782150608273 536870927 true] #datascript/Datom [207 :block/title "" 536870927 true] #datascript/Datom [207 :block/uuid #uuid "15c75b6a-c926-4c30-be6c-1aa53f5e48ee" 536870927 true]) :error "#error {:message \"DB write failed with invalid data\", :data {:tx-meta {:outliner-op :batch-import-edn, :db-sync/tx-id #uuid \"0ca176ff-dee0-45dc-b907-8a2cb5955813\", :client-id \"4d86d058-192d-4af8-ac0f-74f053a54654\", :local-tx? true, :outliner-ops (), :logseq.db.sqlite.export/imported-data? true}, :tx-data (#datascript/Datom [206 :block/uuid #uuid \"6a396945-247c-4223-9246-c17832e6032c\" 536870927 true] #datascript/Datom [199 :block/updated-at 1782150519240 536870927 false] #datascript/Datom [199 :block/updated-at 1782150608273 536870927 true] #datascript/Datom [199 :block/created-at 1782150519240 536870927 false] #datascript/Datom [199 :block/created-at 1782150608273 536870927 true] #datascript/Datom [207 :block/page 206 536870927 true] #datascript/Datom [207 :block/order \"b1c\" 536870927 true] #datascript/Datom [207 :block/parent 206 536870927 true] #datascript/Datom [207 :block/updated-at 1782150608273 536870927 true] #datascript/Datom [207 :block/created-at 1782150608273 536870927 true] #datascript/Datom [207 :block/title \"\" 536870927 true] #datascript/Datom [207 :block/uuid #uuid \"15c75b6a-c926-4c30-be6c-1aa53f5e48ee\" 536870927 true]), :errors [{:entity-map {:block/tx-id 536870927, :block/uuid #uuid \"6a396945-247c-4223-9246-c17832e6032c\", :block/properties ([:logseq.property/created-by-ref 194]), :db/id 206}, :errors [{:block/title {\"normal-block\" [\"missing required key\"], \"whiteboard-block\" [\"missing required key\"]}, :block/parent {\"normal-block\" [\"missing required key\"], \"whiteboard-block\" [\"missing required key\"]}, :block/order {\"normal-block\" [\"missing required key\"]}, :block/page {\"normal-block\" [\"missing required key\"], \"whiteboard-block\" [\"missing required key\"]}, :block/created-at {\"normal-block\" [\"missing required key\"], \"whiteboard-block\" [\"missing required key\"]}, :block/updated-at {\"normal-block\" [\"missing required key\"], \"whiteboard-block\" [\"missing required key\"]}}]}], :pipeline-tx-data ([206 :block/uuid #uuid \"6a396945-247c-4223-9246-c17832e6032c\" 536870927] [199 :block/updated-at 1782150519240 536870927] [199 :block/updated-at 1782150608273 536870927] [199 :block/created-at 1782150519240 536870927] [199 :block/created-at 1782150608273 536870927] [207 :block/page 206 536870927] [207 :block/order \"b1c\" 536870927] [207 :block/parent 206 536870927] [207 :block/updated-at 1782150608273 536870927] [207 :block/created-at 1782150608273 536870927] [207 :block/title \"\" 536870927] [207 :block/uuid #uuid \"15c75b6a-c926-4c30-be6c-1aa53f5e48ee\" 536870927] [206 :logseq.property/created-by-ref 194 536870928] [207 :logseq.property/created-by-ref 194 536870928] [206 :block/tx-id 536870927 536870929] [199 :block/tx-id 536870922 536870929] [199 :block/tx-id 536870927 536870929] [207 :block/tx-id 536870927 536870929])}}"
hk [Error]: DB write failed with invalid data
at new hk (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:619195)
at jk (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:619494)
at ik (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:619455)
at G2a (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:1522979)
at r2.j (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:1529924)
at J2a (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:1524168)
at s2 (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:1523739)
at tnb (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:2054434)
at Function. (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:2215701)
at jba (/home/davidak/Projekte/Logseq QA/Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622/resources/app.asar/js/db-worker-node.js:2:475124) {
data: S {
T: null,
W: 4,
G: [
[w], [S], [w],
[rf], [w], [Q],
[w], [rf]
],
C: null,
F: 16647951,
I: 401412
},
cause: null,
description: undefined,
number: undefined,
fileName: undefined,
lineNumber: undefined,
columnNumber: undefined
}
```

### Browser, Desktop or Mobile Platform Information

NixOS 25.11.10684.8fd9daa3db09
Logseq-linux-x86_64-2.0.1-alpha+nightly.20260622

### Additional Context

It works the other way around: Import the tag first and then the page that uses the tag.

### Are you willing to submit a PR? If you know how to fix the bug.

- [ ] I'm willing to submit a PR (Thank you!)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Import EDN data command and reproduce the two-step page-then-base-tag import using the payload's EDN examples. Inspect the validation failure reported by db-worker-node.js, especially the existing class entity and missing block fields. Done means both imports succeed without the invalid-data database error.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, sqlite
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.