db-sync server: CLI bulk upserts fail against E2EE graphs (tx-rejected invalid data)

Đang mở
#1,528 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
cli, databases, security

Hướng nghiên cứu

Start by tracing the logseq-cli upsert commands and the sync worker path that queues and sends transactions; the issue does not name source files or tests. Check how graph E2EE metadata and password handling are currently read, then reproduce the rejected transaction with an E2EE graph. Done means the CLI encrypts writes correctly or fails locally before queuing plaintext transactions when no password is available.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug: logseq-cli fails to encrypt payloads for E2EE graphs, resulting in silent local success and remote tx-rejected

Environment

  • OS: macOS (darwin arm64) and NixOS
  • Logseq Version: 2.0.2 Beta (Revision: 533ac4382a7b69baa98de3a973bff90305b212dc)
  • CLI Execution: Wrapped via ELECTRON_RUN_AS_NODE=1 node dist/logseq.js

Description

When running logseq-cli commands (upsert page, upsert block) against an End-to-End Encrypted (E2EE) graph, the CLI successfully writes to the local transaction queue but fails to encrypt the payload. The sync worker pushes raw plaintext datoms to the sync server, which immediately rejects them with DB write failed with invalid data.

Because the CLI runs under a raw Node environment (ELECTRON_RUN_AS_NODE=1), it bypasses the Electron renderer and does not have access to the safeStorage native API to decrypt the Logseq E2EE macOS keychain blob (["~btn5rO..."]).

Steps to Reproduce

  1. Enable E2EE on a graph in Logseq Desktop (e.g., <my-graph>).
  2. Start the CLI sync worker:
    logseq sync start --graph <my-graph> --output json
  3. Execute a write operation:
    logseq upsert page --graph <my-graph> --page "New Page Test" --output json
  4. The CLI returns success: {"status":"ok","data":{"result":[32982]}}
  5. Check sync status:
    logseq sync status --graph <my-graph> --output json

Actual Behavior

The sync status reports a fatal tx-rejected error. The error-detail reveals the server rejected the transaction because the :tx-data contains raw plaintext datoms instead of the expected encrypted ciphertext blob.

{
  "code": "tx-rejected",
  "message": "tx-rejected",
  "data": {
    "type": "db-sync/tx-rejected",
    "repo": "logseq_db_<my-graph>",
    "message-type": "tx/reject",
    "reason": "db transact failed",
    "error-detail": "#error {:message \"tx entry apply failed\", :cause #error {:message \"DB write failed with invalid data\", :data {:tx-meta {:op :apply-client-tx, :client-revision \"533ac43\", :outliner-op :create-page}, :tx-data ([:db/add \"6af5d87a-eba3...\" :block/uuid #uuid \"6af5d87a-eba3...\"] ...) } }}"
  }
}

Expected Behavior

  1. The CLI should recognize the graph is E2EE (metadata.json or config.json).
  2. It should either:
    • Extract the master key and decrypt the E2EE password (currently impossible via ELECTRON_RUN_AS_NODE).
    • Allow passing the raw unencrypted password securely via a CLI flag or environment variable (e.g., LOGSEQ_E2EE_PASSWORD) during upsert.
    • Hard-fail the upsert command immediately locally if the graph is E2EE and no password is provided, rather than returning status: ok and corrupting the sync queue with rejected plaintext transactions.

Impact

CLI-driven bulk imports, programmatic upserts, and background agents are completely blocked from writing to E2EE graphs. The local DB worker gets wedged trying to push the invalid transaction, requiring manual local transaction rollback or worker restarts.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
29
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của logseq/db-test

Tất cả issue của logseq/db-test

Issue tương tự

Thêm issue về CLI

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.