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

Abierto
#1,528 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Sin datos de lenguaje
Estrellas
29
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de logseq/db-test

Todos los issues de logseq/db-test

Issues similares

Más issues de CLI

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.