zeroclaw-labs/zeroclaw · error

JSONL session contains no valid messages to import

Error message

JSONL session {name} contains no valid messages to import

What it means

Validation failure while importing a JSONL session inside migrate_from_jsonl_with_handlers: the file contained non-whitespace source lines, but none of them parsed as a valid ChatMessage. An import that would produce an empty SQLite session is rejected rather than silently completing, and the staged file is left for inspection.

Solutions

  1. Check the JSONL file for corrupt lines; supply a session file containing at least one valid message.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zeroclaw-infra/src/session_sqlite.rs:666 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/f0c52b44a052c85c. Report an issue: GitHub.

Appendix: source

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

                                continue;
                            }
                        };
                        if line.is_empty() {
                            continue;
                        }
                        has_non_whitespace_source = true;
                        let Ok(message) = serde_json::from_str::<ChatMessage>(line) else {
                            continue;
                        };
                        insert
                            .execute(params![key, message.role, message.content, now])
                            .with_context(|| format!("Failed to import JSONL session {name}"))?;
                        inserted += 1;
                    }
                }

                if inserted == 0 && has_non_whitespace_source {
                    bail!("JSONL session {name} contains no valid messages to import");
                }
                tx.execute(
                    "INSERT INTO session_metadata \
                     (session_key, created_at, last_activity, message_count) \
                     VALUES (?1, ?2, ?3, ?4)",
                    params![key, now, now, inserted],
                )
                .with_context(|| format!("Failed to record metadata for JSONL session {name}"))?;
                tx.execute(
                    "INSERT INTO jsonl_import_receipts \
                     (source_name, session_key, source_hash, source_len, imported_at) \
                     VALUES (?1, ?2, ?3, ?4, ?5)",
                    params![name, key, source_hash, source_len, now],
                )
                .with_context(|| format!("Failed to record JSONL import receipt for {name}"))?;
                receipt_observed_or_commit_attempted = true;
                tx.commit()
                    .with_context(|| format!("Failed to commit JSONL import for {name}"))?;

View on GitHub (pinned to 88bb9c8533)