Repository navigation
fix(import): EDN and file-graph import - #13886
yuxi-liu-wired wants to merge 33 commits into
Conversation
| (or (some->> (get-route-page-uuid) (vector :block/uuid)) | ||
| (get-in (first (state/get-editor-args)) [:block :block/page :db/id]) |
There was a problem hiding this comment.
🟡 Page export targets a block instead
On a block UUID route, get-current-page-id selects the block instead of its parent page. Page export then exports the wrong entity.
Learn more
A page route can identify a block, not just a page. redirect-to-page! routes a block UUID to :page when it has no named heading route, and the page component can render an entity with :block/page. The route-first lookup returns that block's UUID directly, while export-page-data passes the result to page export as a page ID. The prior editor-state lookup used the block's parent page ID.
Example: Navigate to an ordinary block using its UUID, then run “Export page EDN data.” The export selects the block entity instead of the page containing that block.
Recommended fix: Resolve the route UUID to its entity and use its :block/page when present, falling back to the entity itself only when it is a page. Preserve the editor-state fallback when the route cannot be resolved.
Was this helpful? React with 👍 or 👎 to provide feedback.
| (and (= :batch-import-edn (:outliner-op tx-meta)) | ||
| (not (:import-db? tx-meta)))) |
There was a problem hiding this comment.
🔍 Direct worker imports retain the search gap
The worker import endpoint sets the imported-data flag without :batch-import-edn. Its imports still skip search sync; confirm whether this endpoint serves existing graphs.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Thanks for the review. 1. A route that opens a block as a page ( 2. |
472a73b to
34e6f34
Compare
34e6f34 to
80242e2
Compare
…ace, so it merges cleanly with logseq#13886 The test this PR added to import_test.cljs sat at the same place as the ones logseq#13886 adds there, so the two PRs conflicted and the nightly merge left one of them out. The test is unchanged; it now lives in frontend.handler.db-based.import-edn-dialog-test, which carries the requires and the sample EDN it needs, and import_test.cljs is back to master's.
…mmits conflicted one by one with the stack)
f26de41 to
2a21610
Compare
…ace, so it merges cleanly with logseq#13886 The test this PR added to import_test.cljs sat at the same place as the ones logseq#13886 adds there, so the two PRs conflicted and the nightly merge left one of them out. The test is unchanged; it now lives in frontend.handler.db-based.import-edn-dialog-test, which carries the requires and the sample EDN it needs, and import_test.cljs is back to master's.
…mmits conflicted one by one with the stack)
…mmits conflicted one by one with the stack)
…mmits conflicted one by one with the stack)
edcb8c8 to
0bad0fe
Compare
…ace, so it merges cleanly with logseq#13886 The test this PR added to import_test.cljs sat at the same place as the ones logseq#13886 adds there, so the two PRs conflicted and the nightly merge left one of them out. The test is unchanged; it now lives in frontend.handler.db-based.import-edn-dialog-test, which carries the requires and the sample EDN it needs, and import_test.cljs is back to master's.
…mmits conflicted one by one with the stack)
…mmits conflicted one by one with the stack)
…ace, so it merges cleanly with logseq#13886 The test this PR added to import_test.cljs sat at the same place as the ones logseq#13886 adds there, so the two PRs conflicted and the nightly merge left one of them out. The test is unchanged; it now lives in frontend.handler.db-based.import-edn-dialog-test, which carries the requires and the sample EDN it needs, and import_test.cljs is back to master's.
0bad0fe to
fc70e12
Compare
…mmits conflicted one by one with the stack)
Importing a file graph with "Import all tags" produced an invalid entity that was both a class and a property when a tag and a property had the same name in a file, for example `#scheduled` on one block and `scheduled:: true` on another. The import reported invalid blocks and the entity could not be deleted. The import creates a separate class and property page for the two. The page of the property is created from the ref page of the name, which can carry the class attributes of the tag. Its properties are saved for the property page, including `:logseq.property.class/extends`, which a property cannot have. The properties saved for a property page no longer include `:logseq.property.class/extends`. The test imports a file with a tag and a property of the same name, for a name of a built-in property and for another name. Fixes logseq/db-test#1009
Importing a file graph that has a page with a `template::` property, for example a page file that starts with `template:: tt`, failed with "No property schema found for nil" and nothing was imported. Templates are blocks in a DB graph, and the importer converts the template property of a block into a Template block. The template property of a page was mapped to a DB property that does not exist, which left a nil property ident. The importer now ignores `template::` and `template-including-parent::` on a page and reports them in the ignored properties, like the other file properties that have no DB equivalent. The test imports a page with a template property.
…he title
Importing a block with `SCHEDULED:` or `DEADLINE:` on the line after its title
and properties after that left the property lines in the block title, so the
text was both in the title and in the properties:
- planned block
SCHEDULED: <2026-01-05 Mon>
kind:: v1
became a block titled "planned block\nkind:: v1" with the property `kind`.
The importer removes properties from a block title only when they directly
follow the first line, and it removed the planning lines after that.
It now removes the planning lines first, so the properties follow the first
line when the properties are removed.
The test imports a block with planning lines and properties.
Importing a block whose first line is a table left the properties after it in
the block title, so the text was both in the title and in the properties:
- | a | b |
|---|---|
| c | d |
key:: v
The importer removes properties from a block title only when they directly
follow the first line, which is the case for a title of one line, but not for a
table of several lines.
When the block starts with table lines, the properties are now removed after
those lines.
The test removes properties after a table, and keeps the lines of a block whose
first line is text.
…iles use text
Importing a file graph in which a property is a checkbox or a number in one
file and text in a later file failed on the later file with "Expected number
or lookup ref for entity id, got nil", and that file was skipped:
a.md - x
rating:: true
b.md - y
rating:: text1
The importer changes the type of the property to text and rewrites the values
that exist. It retracted the old values as entities, which is right for a text
value but not for a checkbox or a number, which are stored as the value itself,
so it retracted the entity nil.
The importer now retracts a value that is an entity as an entity and any
other value as a value of the property.
The tests import the file pairs above, once with the boolean on a block and
once with it on a page.
Importing a block with a property whose value is a block ref, `rating:: ((<uuid>))`, kept the literal `((uuid))` in the property value. The value showed the text of the ref instead of the referenced block, and it was not a reference of the block that it points to. The importer converts `((uuid))` to `[[uuid]]` in block titles, but the text of a property value block was not converted. The importer now converts block refs in the text of property value blocks and adds the refs to them. The test imports a block ref in a property value, and one to a block that does not exist.
Importing a file in which a block other than the first has a `title::`
property renamed the whole page to that title. A journal page was not created
at all, and its blocks went to a page with the title of the block.
- a1
- b1
title:: xt
The importer took the page name from the first properties node anywhere in the
file, including the properties of a block.
The importer now takes the page name only from the page properties, which come
before the first block.
The test imports a page and a journal with a title property on a block, and a
page that has a title property of its own.
…class
Importing a file graph with "Import all tags" created a second page for a
namespaced tag when the tag's page already existed as a namespace page:
ns___a___b.md - x1
other.md - o1 #ns/a
The page `a` under `ns` stayed a page with the child `ns/a/b`, and a separate
class `a` was created for the tag, so the block was tagged with a node other
than the one the namespace is built on.
The importer only looked for an existing class by the name and the namespace
of the tag. When the tag has no class but there is a page with that namespaced
name, the tag is now converted into the class on that page, so the page, the
class and the namespace are one node.
The test imports the two files above.
…ated the page The import still produced an entity that was both a class and a property in one case of logseq/db-test#1009: a file referenced the page of a name, and a later file had a page of that name that is the tag `tags:: [[scheduled]]` of a block and also the property `scheduled:: true` of another. The page of the name existed from the first file. The later file turned it into a class, and the import also turned the existing page into the property, because it only knew that a page was a class when an earlier import had made it one. An existing page that becomes a class in the file now keeps being the class and the property gets its own entity, like when the class exists already. The test imports the two files above. Fixes logseq/db-test#1009
…of the import The previous change that turns `((uuid))` in a property value into `[[uuid]]` also added the ref to the value block. When the referenced block is imported in a later file, the ref pointed at a block that did not exist yet, and the import failed with "Nothing found for entity id [:block/uuid ...]". The refs of a block are built from its title when the import is finalized, as for the title of any block, which works for a block that is imported later. The importer now only converts the text of the property value block.
…it-pages-and-properties-tx stays under the large-vars limit
…blocks, so db.cljs merges cleanly with logseq#13786 The check this PR added to ldb/transact! for an EDN import's tx-meta sat on the same lines as the one logseq#13786 adds there (whether to expand and clean up deletes), so the two PRs conflicted and the nightly merge left one of them out. transact! is back to master's; expand-delete-blocks-tx and update-refs-history, which it passes tx-meta to, now do nothing for an import. Same behaviour for the import, so nothing changes for the user.
… own page Importing a file graph with the pages projects/b and b gave no root page b when projects/b was mentioned in an earlier file. Every later [[b]] linked to projects/b, and the blocks of pages/b.md were appended to projects/b. With the files in the other order the import made two pages, so the result depended on file names. The db stores the namespace page projects/b with the name b. Three name lookups in the import found it by the bare name b: the page uuid from extract, the existing-page fallback in lookup-imported-page-uuid and the page entity in page-name-string->map. The import's own name index keys namespace pages by their full name, so these db lookups were the only path that matched. When importing, gp-block/get-page now skips pages with a namespace parent, and the three lookups use it. Test: exporter-page-merge-test imports a/b before b, and a [[projects/b]] ref before a [[b]] ref, and checks there are two pages with their own blocks and refs.
…l #Page
Importing a file graph with journals/2023_06_21.md and pages/Jun 21st, 2023.md gave a journal page tagged both #Journal and #Page. The page failed validation ("should not have other built-in page tags when tagged with #Page"), and every later write to it, including deleting it, failed with "DB write failed with invalid data".
The journal file creates the page with #Journal first. For the page file, build-existing-page runs update-page-tags on the incoming page map, which adds #Page when the incoming tags have no page class. It does not look at the tags the existing page already has.
build-existing-page now leaves #Page out when the existing page already has another page class (#Journal, #Whiteboard, a tag or property).
Test: exporter-page-merge-test imports a journal file and a page file for the same date, with and without page tags, and checks the page is a journal without #Page, the graph validates and the page can be deleted.
Fixes logseq/db-test#1378
With pages/b.md, pages/projects___sub___b.md and pages/sub___b.md, the import resolved the parent sub of sub/b to projects/sub, so there was no page sub and two pages b under projects/sub. The fix for the namespace page lookup by bare name also covers this parent lookup; this test pins it.
With pages/Jun 21st, 2023.md imported before journals/2023_06_21.md, master also gave a journal tagged #Journal and #Page that did not validate and could not be deleted. The page file creates the journal page, and the journal file then adds #Page through build-existing-page, which the fix for logseq/db-test#1378 now prevents. This test pins that order.
…to a class With convert-all-tags? on (the import's default), a block with #[[Dec 31st, 2025]] turned the journal page for that day into a class: tagged #Journal and #Tag, with a user class ident. The graph failed validation (journal-day is not allowed on a class). convert-tag? decided by the tag's name only, so a journal day was converted like any other tag. convert-tag? now takes the tag page and does not convert a journal day. The tag stays a ref to the journal page, as it does with convert-all-tags? off. Test: exporter-convert-tags-test imports #[[Dec 31st, 2025]] with and without the journal file and checks the journal is not a class, the block refs it and the graph validates.
…ay one page each The file-graph importer still merged or doubled pages in import orders the earlier fixes did not cover: - A pages/ file named like a journal file of the import (pages/Dec 31st, 2025.md next to journals/2025_12_31.md), imported first in a graph whose config.edn has no journal title format, became a plain page. The journal file then merged into it: a page tagged #Journal and #Page without a journal day, its blocks on no page, refs pointing elsewhere, and deleting it failed with "DB write failed with invalid data". - With convert-all-tags? on, #projects/x made a class x that extends projects. A later pages/x.md or [[x]] found that class by the bare name x, so the root page x was never created and its blocks went to the class. - With convert-all-tags? on, [[work/b]] and then #work/b made a page b and a class b, both under work. Causes: the page file is not recognized as a journal without the title format, while the import indexes journal files by their canonical title. A namespaced class has no :block/parent, only an extends, so the namespace-child check in the bare-name lookup missed it; the import's name index also keyed the class's page map, saved without its parent, by its bare name, and read :block/tags with contains?, which is false on the vector a new class carries. The class built for #work/b took the tag's own new uuid instead of the uuid of the page work/b already in the index. Changes: a page whose name is a journal file of the import becomes that journal (uuid, journal day, #Journal) before it is built. gp-block/get-page skips classes that extend a class other than Root. The name index skips the bare name of a uuid that is also saved under its full name, and reads tags as a collection. A namespaced tag converted to a class takes the uuid of the page of that full name when there is one, so the page becomes the class. Tests: exporter-page-merge-test imports a page file before its journal file through export-file-graph with a config.edn without a journal title format; exporter-convert-tags-test imports #projects/x before pages/x.md and [[x]], and [[work/b]] before #work/b. All fail on the previous commit. The importer collision fuzzer has 0 journal-and-page-tag and 0 page-duplicate failures in seeds 1-20.
A page file with alias:: [[Jan 5th, 2026]] imported before journals/2026_01_05.md made the whole import fail with "Nothing found for entity id [:block/uuid #uuid "00000001-2026-0105-0000-000000000000"]".
The import gives a journal of the import its uuid before the journal file is imported, and update-page-alias wrote each alias as a [:block/uuid ..] lookup ref, which fails when that page does not exist yet.
The alias is now a {:block/uuid ..} map, which the journal file later fills in, as block refs already are.
Test: exporter-page-merge-test imports the aliasing page before the journal file through export-file-graph and checks the alias is the journal and the graph validates. It fails on the previous commit.
With convert-all-tags? on (the import's default), #x or tags:: x in a file imported after #work/x went to the class work/x. The block's tag and the page's tags then depended on the file order: the same graph imported in another order tagged it with a class x, and the page x was a #Tag in one order and a #Page in the other. find-existing-class looked up a tag without a namespace by its name only. A namespaced class work/x is stored with the name x and extends work, so it matched. That lookup now skips namespaced classes, as the page lookups by bare name already do. Test: exporter-convert-tags-test imports #work/x before #x and checks that x is its own root class. It fails on the previous commit.
A pages/ file named like a journal day (pages/Jan 5th, 2026.md) with no journal file for that day was a plain page when it was imported first. A later [[Jan 5th, 2026]] or alias:: [[Jan 5th, 2026]] in another file is a journal ref and added #Journal to that page: a page tagged #Journal and #Page without a journal day, which fails validation and cannot be deleted. With the other file first, the import made a valid journal. The importer reads pages/ files with skip-journal?, so their titles are not converted to journals, while refs and aliases to the same name are. The page of a pages/ file whose title is a journal title in the graph's format, or the title of a journal file of the import, is now built as that journal (journal uuid, day and canonical name, #Journal instead of #Page). This replaces the earlier rule that only covered names of journal files of the import. Test: exporter-page-merge-test imports pages/Jan 5th, 2026.md before a page that aliases it, through export-file-graph, and checks there is one valid journal holding the page file's block. It fails on the previous commit.
…eplace part of it `- x #A/B #a` imported as `x [[a]]/B [[a]]`: the block lost its link to A/B and showed a broken `/B`. Tags are replaced ignoring case and as plain text, in the order sort-refs gives, which compares titles case-sensitively and put "a" before "A/B", so `#a` replaced the `#A` of `#A/B`. The same held for `#Foo-bar #foo`. Tags are now replaced longest title first (nested page titles still first), so a tag that is the start of another is replaced after it. Found by the importer collision fuzzer on the nightly (seed 4024); master has it too.
… that still fails export-file-graph-fails-fast-with-relative-path-and-reason (from master) made pages/T.md fail with a page `template::` property and pages/B.md with a boolean property later used as text. This branch fixes both, so those files now import and the test saw no failure. Both page files now use the query-sort-by input of the journal case, which still fails; the assertions on the error's path and reason are unchanged.
66dfd5c to
b2c136e
Compare
…ace, so it merges cleanly with logseq#13886 The test this PR added to import_test.cljs sat at the same place as the ones logseq#13886 adds there, so the two PRs conflicted and the nightly merge left one of them out. The test is unchanged; it now lives in frontend.handler.db-based.import-edn-dialog-test, which carries the requires and the sample EDN it needs, and import_test.cljs is back to master's.
…mmits conflicted one by one with the stack)
Combines the PRs of this theme, to keep the number of open PRs down; the commits are unchanged. CI's unit suite passes on the combined branch.
fix(import): EDN export and import keep pages, history, search and the target block (was #13886)
Fixes logseq/db-test#1381, fixes logseq/db-test#958, fixes logseq/db-test#1004, fixes logseq/db-test#1420, fixes logseq/db-test#1385.
This PR fixes five EDN import/export bugs. Each fix is its own commit with its own test.
What the user sees
graph import --type ednof a full:graphexport drops the property history (such as a task's status history). The CLI prints "Imported" and exits 0.Cause
get-current-page-idonly read the page of the last edited block from it. Despite its docstring it never looked at the route, so it returned nil.<current-import-blockreturns nil after warning "No block found" (the command palette clears the editor state), andimport-edn-data-from-formtreated nil as "no block needed" and went on to build the import of a block export without a block.ldb/transact!then ran its cleanup for deleted blocks over that transaction, which saw the imported history records referring to ids that the same transaction retracts, and retracted them. The existing import tests transact withd/transact!into an empty graph, so they did not catch it.Change
get-current-page-idlooks at the page in the route first and returns[:block/uuid <page-uuid>], which pull and export-edn accept, then falls back to the last edited block as before (src/main/frontend/util/page.cljs).check-for-existing-entitiesrecords the uuid remap of existing classes and properties, as it already did for pages matched by title, so the exported page and references to it use the existing node and its blocks are added to it (deps/db/src/logseq/db/sqlite/export.cljs).import-edn-data-from-formcloses without importing when it is importing a block export and<current-import-blockreturned nil. Other kinds of export are still imported without a current block (src/main/frontend/handler/db_based/import.cljs).ldb/transact!skips the deleted blocks cleanup for transactions marked as imported data bylogseq.db.sqlite.export, since the import replaces the data and has nothing to clean up (deps/db/src/logseq/db.cljs).:import-db?) and syncs for an EDN import into an existing graph. Other imports are unchanged (src/main/frontend/worker/db_listener.cljs).Tests
get-current-page-id-testinsrc/test/frontend/util/page_test.cljscovers the route page with the editor state cleared, the route preferred over a stale editor state, and the two editor fallbacks. Without the fix: 2 failures. With the fix: passes, and the whole unit suite passed.import-class-and-property-pages-when-they-exist-with-different-uuidsindeps/db/test/logseq/db/sqlite/export_test.cljsimports the pages of a class and a property into a graph where both exist with other uuids. Without the fix: 6 failures (validation error, blocks missing from the existing pages, stub pages with the exported uuids). With the fix: passes.graph-datom-import-through-ldb-transact-keeps-property-historyin the same file imports a graph with property history into a graph that already has content, transacting withldb/transact!like the worker's:thread-api/import-edn. Without the fix: 1 failure (0 history records after import, 1 expected). With the fix: passes. The wholedeps/dbsuite passes with all thedeps/dbfixes (202 tests, 772 assertions, 0 failures).import-edn-block-without-current-block-does-not-import-testandimport-edn-page-without-current-block-imports-testinsrc/test/frontend/handler/db_based/import_test.cljssubmit the Import EDN form with no block being edited. Without the fix: 2 failures (an import is applied, two notifications are shown). With the fix: passes.db-listener-syncs-search-for-edn-import-into-existing-graph-testinsrc/test/frontend/worker/db_listener_test.cljschecks the search sync for an EDN import into an existing graph and for one that creates a graph. Without the fix: 1 failure. With the fix: passes. The olderdb-listener-skips-search-sync-for-imported-data-testonly checks that nothing is synced right away and the listener syncs asynchronously, so the new test waits for it.pnpm cljs:run-test) passed exceptfrontend.persist-db-test/electron-import-and-download-open-real-worker-in-fresh-graphs(a "Worker request timeout" while another build and suite were running on the machine); that namespace passes when run alone (46 tests, 208 assertions, 0 failures).fix(import): file-graph import keeps tables in quotes and Zotero PDF assets (was #13891)
Fixes logseq/db-test#1048, fixes logseq/db-test#1408, fixes logseq/db-test#1469, fixes logseq/db-test#1009.
This PR fixes bugs in the file graph to DB graph importer (
deps/graph-parser), most found by a fuzzer that imports generated markdown graphs and checks that nothing is lost, duplicated or invalid. Each fix is its own commit with its own test.What the user sees
#+BEGIN_QUOTEwith text and a markdown table, or> | a | b |) is dropped by the import.{{zotero-linked-file}}gives as an absolute path does not become an asset when the graph has a Zotero linked attachment base directory, and the imported PDF can't be opened (the viewer looks in<base>/<absolute path>).#scheduledandscheduled:: true) can end up as one invalid entity that is both a class and a property.template:: xaborts the whole import ("No property schema found for nil").SCHEDULED:orDEADLINE:and then properties keeps the property lines in its title, so the text is both in the title and in the properties. The same happens for properties after a table.rating:: ((uuid))) stays as literal((uuid))text.title::property on any block other than the first renames the whole page, and a journal with one is not created.#ns/acreates a second pageawhenns/a/balready createdns/aas a namespace page.Cause and change
498b4804a2):ast->text, which writes the content of quotes into the block title, had no branch for a Table node. It writes a Table node as a markdown table now.390394e147):resolve-asset-datajoined the base directory with the path of the macro even when it is absolute. It uses an absolute path (including a Windows drive path) as is. (a0e98a3b7e) The PDF viewer'sget-zotero-local-pdf-path(src/main/frontend/extensions/pdf/assets.cljs) did the same with the importedzotero-link://<absolute path>, so opening the PDF or an annotation looked in<base>/<absolute path>. It returns an absolute path as it is and joins only a relative one.69708710ac):<ensure-asset-data!creates the asset of a PDF that can't be stat'ed only forexternal?PDFs, and a Zotero PDF, which only points at the Zotero item, wasn't one. It is treated as external now.41fe859006,43060e7a62): The tag and the property of a name get distinct entities (the class and the property page), but the properties saved for the property page included:logseq.property.class/extendsfrom the tag of the same name, which a property can't have; they are dropped now. A second case: when an earlier file created the page of the name, the file that makes it a class also converted that existing page into the property; an existing page that becomes a class in the file now stays the class and the property gets its own entity.template::(1005fb27ee): the property was mapped to a DB property that doesn't exist.template::andtemplate-including-parent::on a page are ignored and reported in the ignored properties.aff441a9f3): properties are only removed from a title when they directly follow the first line, and the planning lines were removed after that. They are removed first.74f35c411e):remove-propertiesalso skips the table lines of a block that starts with a table.c943486491): the importer retracted the old values of the property as entities, and a checkbox or number value is not an entity (it retracted the entity nil). A value that is an entity is retracted as an entity, any other value as a value of the property.c9a17a08e2,bb6a00eb40): the text of a property value block was not converted from((uuid))to[[uuid]]as block titles are. The first commit also added the refs, which failed the import when the target block comes from a later file; the second leaves the refs to the finalizing of the import, which builds them from the title.title::(f4ea81df98): the page name came from the first properties node anywhere in the file; only the page properties, which come before the first block, count now.7743ad7b94): the importer only looked for an existing class by the name of the tag. When there is a page with that namespaced name, the tag is converted into the class on that page.Tests
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs:import-table-in-block,import-zotero-linked-file-with-absolute-path,import-zotero-pdf-annotations-when-the-pdf-is-missing,import-tag-and-property-of-same-name-when-the-page-has-a-file-convert-all-tags,import-tag-and-property-of-same-name-when-an-earlier-file-created-the-page-convert-all-tags,import-page-template-property,import-properties-after-planning-line-are-not-in-title,import-property-changing-from-boolean-to-text,import-page-property-changing-from-boolean-to-text,import-block-ref-in-property-value,import-title-property-of-a-block-does-not-rename-the-page,import-namespaced-tag-of-a-namespace-page-convert-all-tags. Each fails on master and passes with its fix.deps/graph-parser/test/logseq/graph_parser/property_test.cljs:test-remove-properties-after-table.src/test/frontend/extensions/pdf/assets_test.cljs:get-zotero-local-pdf-path-test(main bundle; fails without the fix, whole unit suite passes).deps/graph-parsersuite passes withpnpm test -e integration(125 tests, 1437 assertions, 0 failures). The^:integrationtestexport-docs-graph-with-convert-all-tagstimes out ("Import timed out after 30000ms") in this environment on master as well, so it could not be run to completion.Fuzzer, master vs this branch
40 generated graphs (seeds 1 to 40), number of failures per property;
FUZZ_REPORTED=1adds the inputs of the aborting bugs. Full lists in~/tmp/fuzz-*.out.block-missing,lost-text/block-token,lost-text/quote-first-table-cell,lost-text/table-header(tables in quotes)block-parentprop-text-left-in-title/after-planning-lineprop-text-left-in-title/no-planning-linevalid,tag-and-property,prop-key-lost/scheduledlost-text/asset-png-label,lost-text/asset-pdf-label(#1081)prop-key-lost/*page-missing/prop-*-ref(not minimized)page-missing/ref,ref-lostFUZZ_REPORTED=1:block-ref-syntax-left/property-valueFUZZ_REPORTED=1:import-errorThe 13
no-planning-lineand theprop-key-lostfailures are the same quote blocks:> | a | b |followed bykey:: v. A line without>after a quote line is a lazy continuation of the quote, so the properties stay in the quote text and are not parsed. They were hidden behind the missing quote tables on master.Not included
build-new-assetputs every asset on the Asset page) needs a choice of which page an asset belongs to when several pages reference it.topiccase of the second Feat: add google login #1009 test) fails with "Conflicting upserts" on master and on this branch;[[Jan 6th, 2026]]style values in text properties leave no journal page (not minimized).fix(import): file-graph import keeps pages of one name apart, whatever the file order (was #13911)
Fixes logseq/db-test#1378.
These commits came from #13911, which is now the storage PR only. The import collision fuzzer imports each graph in three file orders and checks it. On this branch it passes all of seeds 1-40, with every property at 0.
In
convert-tag-to-class, this PR's lookup of an existing namespace page in the db (find-existing-namespace-page-uuid) and #13911's lookup in the import's name index are combined. A tag#work/bbecomes the class of an earlier pagework/b, whether that page is already in the db or only in the current file.A page named like a namespace page's last part is merged into the namespace page
What the user sees. In a file graph with the pages
projects/bandb, ifprojects/bappears in an earlier file thanb, the import has no root pageb. Every later[[b]]links toprojects/b, and the blocks ofpages/b.mdare appended toprojects/b. With the other file order the import makes two pages, so the result depends only on file names. No warning is shown and the graph validates.Cause. The db stores the namespace page
projects/bwith the nameb. The import's own name index keys namespace pages by their full name, but three db lookups by name found the namespace page by the bare nameb: the page uuid inextract, the existing-page fallback inlookup-imported-page-uuidand the page entity inpage-name-string->map.Change. When importing,
gp-block/get-pageskips pages with a namespace parent, and the three lookups use it.Tests.
logseq.graph-parser.exporter-page-merge-testimportspages/a___b.mdbeforepages/b.md, and a[[projects/b]]ref before a[[b]]ref, and checks that there are two pages, each with its own blocks and refs. It also importsb,projects/sub/bandsub/band checks thatsub/bsits under a root pagesub, not underprojects/sub(the same lookup one level up). All three fail on master.A journal file and a page file for the same date make an undeletable page
What the user sees. A file graph with
journals/2023_06_21.mdandpages/Jun 21st, 2023.md(such page files exist after a change of:journal/page-title-format, or when a date page was created as a normal page) imports a journal page tagged both #Journal and #Page. It fails validation ("should not have other built-in page tags when tagged with #Page"), and every later write to it, including deleting it, fails with "DB write failed with invalid data".Cause. The journal file creates the page with #Journal first. For the page file,
build-existing-pagerunsupdate-page-tagson the incoming page map, which adds #Page when the incoming tags have no page class. It does not look at the tags the existing page already has.Change.
build-existing-pageleaves #Page out when the existing page already has another page class (#Journal, #Whiteboard, a tag or a property).Tests.
logseq.graph-parser.exporter-page-merge-testimports a journal file and a page file for the same date, with and without page tags, and checks that the page is a journal without #Page, that the graph validates and that the page can be deleted. Both fail on master.The same page collisions through other entry points: file order, tags, aliases
The importer collision fuzzer (
mutation/lib/exporter_fuzz_test.cljs, each graph imported in three file orders) still found these on the two fixes above.What the user sees.
pages/file named like a journal file of the import, imported first (for examplepages/Dec 31st, 2025.mdnext tojournals/2025_12_31.md, in a graph whoseconfig.ednhas no:journal/page-title-format), becomes a plain page. The journal file then merges into it. The result is a page tagged #Journal and #Page without a journal day, whose journal blocks are on no page and which cannot be deleted.convert-all-tags?on,#projects/xmakes a classxthat extendsprojects. A laterpages/x.mdor[[x]]lands on that class, so there is no root pagex.convert-all-tags?on,[[work/b]]and then#work/bmake a pageband a classb, both underwork.convert-all-tags?on, a tag naming a journal date (#[[Dec 31st, 2025]]) turns the journal into a class, and the graph does not validate.alias:: [[Jan 5th, 2026]]imported beforejournals/2026_01_05.mdmakes the whole import fail with "Nothing found for entity id [:block/uuid ...]".Cause.
:block/parent, only an extends, so the namespace-child check ingp-block/get-pagemissed it.:block/tagswithcontains?, which is false on the vector a new class carries.#work/btook the tag's new uuid instead of the uuid of the pagework/balready in the index.convert-tag?did not exclude journal days.[:block/uuid ...]lookup ref to a journal page that does not exist yet.Change.
gp-block/get-pagealso skips classes that extend a class other than Root.{:block/uuid ...}maps, as block refs already are.Tests.
exporter-page-merge-testcovers a page file before its journal file (throughexport-file-graphwith aconfig.ednwithout a title format), a date tag, a page file and a journal file in one graph, and an alias of a journal imported before the journal.exporter-convert-tags-testcovers#projects/xbeforepages/x.mdand[[x]],[[work/b]]before#work/b, and a journal date as a tag. Each fails before its fix.Links and tags that depend on the file order
What the user sees.
convert-all-tags?on,#xortags:: xin a file imported after#work/xpoints at the classwork/x. Imported in another order, it points at a classx, and the pagexis a #Tag in one order and a #Page in the other.pages/file named like a journal day (pages/Jan 5th, 2026.md) with no journal file for that day is a plain page when it comes first. A later[[Jan 5th, 2026]]or alias of that name adds #Journal to it, giving a page tagged #Journal and #Page without a journal day that cannot be deleted. With the other order, the import makes a valid journal.Cause.
find-existing-classlooked up a tag without a namespace by name only, and the namespaced classwork/xis stored with the namex.pages/files withskip-journal?, so their titles never become journals, while refs and aliases to the same name do.Change.
find-existing-classskips namespaced classes for a tag without a namespace.pages/file whose title is a journal title is built as that journal: in the graph's title format, or matching a journal file of the import. It gets the journal uuid, day and canonical name, and #Journal instead of #Page. This replaces the earlier rule, which only covered names of journal files of the import.Tests.
exporter-convert-tags-testimports#work/xbefore#x.exporter-page-merge-testimportspages/Jan 5th, 2026.mdbefore a page that aliases it. Both fail before the fix.Shared aliases. When two pages declare the same alias, or an alias declares aliases itself, the source graph has a conflict. The importer keeps the first declaration in import order and reports the others in the import report (
:alias/duplicate-owner,:alias/source-is-alias,:alias/alias-owns-aliases). The app imports files sorted by path, so the first page in path order keeps a shared alias.Fuzzers. The importer collision fuzzer passes all of seeds 1-20 and 21-40, with every property at 0. Before this PR, seeds 1-20 had 14 failing. The fuzzer now leaves reported alias conflicts out of its comparison between orders. The storage fuzzer passes all 30 seeds.
A tag that starts another tag in another case (edcb8c8)
Found by the importer collision fuzzer on the fork's nightly (seed 4024), minimised to one line; master has it too.
- x #A/B #aimported asx [[a]]/B [[a]]: the block lost its link toA/Band showed a broken/B. Tags are replaced ignoring case and as plain text, in the ordersort-refsgives, which compares titles case-sensitively and putabeforeA/B, so#areplaced the#Aof#A/B.#Foo-bar #foohad the same problem.replace-tags-with-id-refsnow replaces the longest title first (nested page titles still first), so a tag that is the start of another one is replaced after it. Tests:logseq.db.frontend.content-tag-prefix-test(2 of 3 fail without the change, all pass with it; the existingcontent-testpasses).Rebase onto master 29fd2ed: master's fail-fast import test
Master's
export-file-graph-fails-fast-with-relative-path-and-reason(deps/graph-parser exporter_test.cljs) used two inputs that this PR fixes as files that must fail the import:pages/T.mdwith a pagetemplate::property ("No property schema found for nil") andpages/B.mdwithvegetarian:: yesafterpages/A.mdset it tofalse. With this PR both import, so the test saw no failure. The test pins the fail-fast error path (the file's path and the reason in the error), so both page files now use the query-sort-by input of the test's journal case, which still fails; the helper's assertions on path, reason and later files are unchanged.