tinyhumansai/openhuman · error · anyhow::Error

open chat.db failed for full-day read ({})

Error message

open chat.db failed for full-day read ({})

What it means

The same chat.db open failure as the incremental path, but raised inside read_chat_day() — the full-day transcript rebuild run before upserting memory docs so day-over-day writes are complete conversations, never partial deltas. Unlike error 290 this variant does not embed the Full Disk Access hint, only the raw SQLite error, so the remedy is less obvious from the message alone.

Source

Thrown at app/src-tauri/src/imessage_scanner/chatdb.rs:114

        out.push(r?);
    }
    Ok(out)
}

/// Read ALL messages for a single `(chat_identifier, day)` slice, inclusive
/// of the day boundary in Apple nanosecond epoch. Used to rebuild full-day
/// transcripts before upserting memory docs — so tick-over-tick we always
/// write the complete conversation for the day, never a partial delta
/// that would overwrite prior content.
pub fn read_chat_day(
    db_path: &Path,
    chat_identifier: &str,
    day_start_apple_ns: i64,
    day_end_apple_ns: i64,
    limit: usize,
) -> anyhow::Result<Vec<Message>> {
    let conn = open(db_path)
        .map_err(|e| anyhow::anyhow!("open chat.db failed for full-day read ({})", e))?;

    let mut stmt = conn.prepare(
        r#"
        SELECT
          m.ROWID            AS rowid,
          m.guid             AS guid,
          m.text             AS text,
          m.attributedBody   AS attributed_body,
          m.date             AS date_ns,
          m.is_from_me       AS is_from_me,
          h.id               AS handle_id,
          c.chat_identifier  AS chat_identifier,
          c.display_name     AS chat_name,
          m.service          AS service
        FROM message m
        LEFT JOIN handle h ON h.ROWID = m.handle_id
        LEFT JOIN chat_message_join cmj ON cmj.message_id = m.ROWID
        LEFT JOIN chat c ON c.ROWID = cmj.chat_id

View on GitHub (pinned to a221052e0d)

Solutions

  1. Apply the same fix as 290: grant/re-grant Full Disk Access to the app binary and restart
  2. Verify the file is present and stable: ls -l ~/Library/Messages/chat.db
  3. If intermittent, distinguish SQLITE_BUSY (transient lock — retry) from CANTOPEN/EPERM (TCC — fix FDA) using the appended error

Example fix

// before (app/src-tauri/src/imessage_scanner/chatdb.rs)
let conn = open(db_path).map_err(|e| anyhow::anyhow!("open chat.db failed for full-day read ({})", e))?;

// after — carry the same FDA remedy as the incremental reader
let conn = open(db_path).map_err(|e| anyhow::anyhow!(
    "open chat.db failed for full-day read ({}). Grant Full Disk Access to OpenHuman: \
     System Settings → Privacy & Security → Full Disk Access.", e))?;
Defensive patterns

Strategy: validation

Validate before calling

// share one guard with the incremental reader before the day rebuild
match std::fs::metadata(db_path) {
    Ok(_) => {}
    Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => {
        log::warn!("[imessage] full-day read skipped: chat.db unreadable (Full Disk Access?)");
        return Ok(Vec::new());
    }
    Err(e) => return Err(anyhow::anyhow!("stat chat.db failed: {e}")),
}

Try / catch

match chatdb::read_chat_day(&db, chat_id, start, end, limit) {
    Ok(msgs) => Ok(msgs),
    Err(e) if e.to_string().contains("open chat.db failed") => {
        log::warn!("[imessage] day rebuild deferred: {e}"); Ok(Vec::new())  // retried next tick
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: The daily-rebuild pass hitting the same condition: FDA revoked between successful incremental scans; chat.db transiently locked or replaced by Messages.app maintenance; file missing on a fresh profile.

Common situations: Permissions reset by a macOS update mid-session; scanner racing a Messages.app db rebuild; the incremental path already failing (290) so the day rebuild fails identically.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16). Data as JSON: /api/errors/645791ebbcd4d60c. Report an issue: GitHub.