Skip to content

Harden partial EDN imports - #12929

Open
megayu wants to merge 10 commits into
masterfrom
fix/import-edn-data-hardening
Open

Harden partial EDN imports#12929
megayu wants to merge 10 commits into
masterfrom
fix/import-edn-data-hardening

Conversation

@megayu

@megayu megayu commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator
  • Reject full-graph datom exports, empty/no-op payloads, and unsupported attributes.
  • Require an active editing target for block imports and preserve it across header and keyboard command-palette flows.
  • Prevent duplicate submissions while keeping repeated imports append-only.
  • Preserve existing page identity, properties, timestamps, collapsed state, tags, and aliases.
  • Keep the hardening scoped to Import EDN Data without changing other importer callers.
  • Skip full validation for structured EDN imports.

fix logseq/db-test#1004 , logseq/db-test#994

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the “Import EDN Data” flow by rejecting unsupported EDN shapes (including full-graph exports), requiring a valid editor target for block imports, preventing concurrent submissions, and preserving existing page identity/metadata when importing partial EDN into an existing graph.

Changes:

  • Add preflight classification for Import EDN Data (full-graph vs partial vs unsupported) and improve UI flow safety (target preservation, duplicate-submit blocking).
  • Extend sqlite import/build/validation to better preserve existing page attributes (UUID/title/name/journal fields, properties, tags, aliases) and to tighten EDN validation behavior for this import path.
  • Add/extend test coverage for the hardened import behavior and new validation rules; add new i18n keys for the new notifications.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/test/frontend/handler/db_based/import_test.cljs Adds CLJS UI-level tests for Import EDN Data preflight, editor-target handling, and duplicate-submit blocking.
src/resources/dicts/zh-cn.edn Adds new Simplified Chinese i18n strings for hardened Import EDN Data messages.
src/resources/dicts/en.edn Adds new English i18n strings for hardened Import EDN Data messages.
src/main/frontend/modules/shortcut/config.cljs Preserves editor context when invoking search via shortcut so downstream commands can reuse the editing target.
src/main/frontend/handler/events/ui.cljs Extends :go/search event handling to accept/update :search/args editor context.
src/main/frontend/handler/db_based/import.cljs Hardens Import EDN Data dialog handling (shape checks, editor target enforcement, submitting lockout, scoped dialog closing).
src/main/frontend/components/header.cljs Captures editor context before pointer focus changes so search-from-header can preserve the editing target.
src/main/frontend/components/cmdk/core.cljs Switches to util/stop for consistent preventDefault+stopPropagation behavior.
deps/outliner/src/logseq/outliner/op.cljs Threads :import-edn-data? into validation so Import EDN Data can use stricter validation behavior.
deps/db/test/logseq/db/sqlite/export_test.cljs Adds unit tests for Import EDN Data validation/shape constraints and metadata preservation/merge behavior.
deps/db/src/logseq/db/sqlite/export.cljs Implements Import EDN Data shape detection, rejects unsupported export metadata, preserves existing-page attributes, and tightens validation reporting.
deps/db/src/logseq/db/sqlite/build.cljs Ensures existing-page updates aren’t treated as “minimal” when alias-merge metadata requires additional txs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deps/db/src/logseq/db/sqlite/export.cljs Outdated
Comment thread src/main/frontend/handler/db_based/import.cljs Outdated
Comment thread src/test/frontend/handler/db_based/import_test.cljs Outdated
Comment thread src/test/frontend/handler/db_based/import_test.cljs
Comment thread src/test/frontend/handler/db_based/import_test.cljs
Comment thread src/test/frontend/handler/db_based/import_test.cljs Outdated
@megayu
megayu force-pushed the fix/import-edn-data-hardening branch from 8e8b8fc to 4d0652e Compare July 21, 2026 06:45
@megayu
megayu requested a review from tiensonqin July 21, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when trying to import exported block

2 participants