Skip to content

fix(export): EDN export of pages, blocks and selections imports back whole - #13744

Closed
yuxi-liu-wired wants to merge 2 commits into
logseq:masterfrom
yuxi-liu-wired:fix/export-selected-nodes-refs
Closed

yuxi-liu-wired wants to merge 2 commits into
logseq:masterfrom
yuxi-liu-wired:fix/export-selected-nodes-refs

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Three ways an EDN export of a page, a block or a selection did not import back whole. Found by fuzzing export → import for every export type (:graph and :graph-human came back with no mismatch).

1. A selected block that another selected block references is exported twice

Selecting alpha and x where x has a node property source:: alpha (or a [[uuid]] ref to alpha) exports alpha twice on the same page: once as a selected node, once as a referenced block (build-uuid-block-export). The import creates a duplicate, or merges the two copies by uuid and the page's block order changes. build-page-export avoids this by dropping its own page; build-selected-nodes-export and build-view-nodes-export passed nothing.

Fix: build-uuid-block-export takes the nodes already in the export (:exported-nodes) and leaves them out. An exported node that is another node's property value keeps its uuid (:include-uuid-fn includes the property value entities), so the value still resolves.

2. A node property value on a nested block fails the import

A child block with source:: [[Alpha]], where page Alpha is not otherwise in the export: the export writes [:build/page {:block/title "Alpha"}] and relies on sqlite.build/add-new-pages-from-properties to create the page, but get-used-properties-from-options reads only each page's top-level :blocks, never :build/children, so the import throws No uuid for page '{:block/title "Alpha"}'. The same block at the top level imports fine.

Fix: get-used-properties-from-options also walks :build/children.

3. A ref inside a referenced block imports as a raw uuid

Exporting a block export [[middle]] where middle is middle [[Beta]]: middle is exported (shallow) with its title, but Beta is not, so the import shows middle [[<uuid>]].

Fix: build-content-ref-export follows refs in the titles of referenced blocks until no new ones turn up. The blocks it starts from include every value of a many node property (a set), not only single values.

Tests

In logseq.db.sqlite.export-test: import-selected-nodes-that-reference-each-other, import-selected-nodes-where-one-is-a-node-value-of-another, import-page-with-node-value-on-child-block, import-block-with-refs-two-levels-deep, import-block-with-node-value-whose-title-has-a-ref. Each fails or errors on master and passes with the fix; the other export tests pass.

The EDN export → import fuzzer (every export type, seeds 1 and 11) finds no mismatch with this PR. The text loops' remaining cases are logseq/db-test#1442.

…whole

- Selected nodes: a selected block that another selected block references was exported a second time; blocks already in the export are no longer added as referenced blocks.
- A node property value on a nested block pointing at a page outside the export failed the import (No uuid for page): sqlite.build now looks at nested blocks when it creates pages from property values.
- A referenced block is exported with its title, so the refs in that title are followed too; before, they imported as raw uuids.
…rty value; follow refs in many node values

With the selected block no longer exported twice, a selected block that is another selected block's node value lost the uuid the value points at (build-export: uuids are not defined). Such a node now keeps its uuid. Property values with many values (sets) were skipped when collecting the blocks whose title refs are followed.
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Combined with the other PRs that change the same files into #13785.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/export-selected-nodes-refs branch October 21, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant