zeroclaw-labs/zeroclaw · error

Refusing to import receipt-less JSONL session

Error message

Refusing to import receipt-less JSONL session {name} over existing SQLite session state for {key}

What it means

Safety refusal inside the JSONL import transaction: the staged file has no committed import receipt, yet the SQLite database already contains rows (sessions or session_metadata) for this session key. Importing a receipt-less file over existing state could duplicate or corrupt messages, so the migration refuses and leaves both sides untouched for manual resolution.

Solutions

  1. Provide the import receipt for the JSONL session, or remove the existing SQLite session state before importing.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zeroclaw-infra/src/session_sqlite.rs:623 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/995217381d6e13ba. Report an issue: GitHub.

Appendix: source

Thrown at crates/zeroclaw-infra/src/session_sqlite.rs:623

                    }
                    tx.commit().with_context(|| {
                        format!("Failed to finish JSONL receipt check for {name}")
                    })?;
                    return Ok(());
                }

                let existing_state: bool = tx
                    .query_row(
                        "SELECT EXISTS(SELECT 1 FROM sessions WHERE session_key = ?1) \
                         OR EXISTS(SELECT 1 FROM session_metadata WHERE session_key = ?1)",
                        params![key],
                        |row| row.get(0),
                    )
                    .with_context(|| {
                        format!("Failed to inspect existing SQLite session state for {key}")
                    })?;
                if existing_state {
                    bail!(
                        "Refusing to import receipt-less JSONL session {name} over existing SQLite session state for {key}"
                    );
                }

                let file = std::fs::File::open(&staged_path)
                    .with_context(|| format!("Failed to open staged JSONL session {name}"))?;
                let now = Utc::now().to_rfc3339();
                let mut inserted = 0_i64;
                let mut has_non_whitespace_source = false;
                {
                    let mut insert = tx
                        .prepare(
                            "INSERT INTO sessions (session_key, role, content, created_at) \
                             VALUES (?1, ?2, ?3, ?4)",
                        )
                        .with_context(|| format!("Failed to prepare JSONL import for {name}"))?;
                    for line in io::BufReader::new(file).split(b'\n') {
                        let line = line.with_context(|| {

View on GitHub (pinned to 88bb9c8533)