tinyhumansai/openhuman · error

failed to query mcp_writes

Error message

failed to query mcp_writes

What it means

Executing the prepared mcp_writes list query (query_map with the bound limit/offset refs) returned an error from SQLite. Preparation succeeded but execution failed — typically a locked database, a datatype mismatch on a bound parameter, or I/O error mid-query. Wrapped with context 'failed to query mcp_writes' and returned as an error to the listing caller (the MCP audit RPC surface).

Source

Thrown at src/openhuman/mcp/audit/store.rs:177

        let refs = bound
            .iter()
            .map(|value| value.as_ref() as &dyn ToSql)
            .collect::<Vec<_>>();
        log::trace!("[mcp_audit] list_writes preparing query");
        let mut stmt = match conn.prepare(&sql) {
            Ok(stmt) => stmt,
            Err(err) => {
                log::warn!("[mcp_audit] list_writes prepare failed error={err}");
                return Err(anyhow::Error::new(err))
                    .context("failed to prepare mcp_writes list query");
            }
        };
        log::trace!("[mcp_audit] list_writes executing query");
        let mapped = match stmt.query_map(refs.as_slice(), row_to_record) {
            Ok(mapped) => mapped,
            Err(err) => {
                log::warn!("[mcp_audit] list_writes query failed error={err}");
                return Err(anyhow::Error::new(err)).context("failed to query mcp_writes");
            }
        };
        let rows = match mapped.collect::<rusqlite::Result<Vec<_>>>() {
            Ok(rows) => rows,
            Err(err) => {
                log::warn!("[mcp_audit] list_writes collect failed error={err}");
                return Err(anyhow::Error::new(err)).context("failed to collect mcp_writes rows");
            }
        };
        log::debug!("[mcp_audit] list_writes exit rows={}", rows.len());
        Ok(rows)
    });
    if let Err(err) = &result {
        log::warn!("[mcp_audit] list_writes failed error={err}");
    }
    result
}

View on GitHub (pinned to 7491200858)

Solutions

  1. Retry the listing once the competing write transaction on the audit DB completes (enable busy_timeout/WAL to avoid lock errors)
  2. Check that bound limit/offset values are within SQLite's integer range
  3. Inspect the underlying SQLite error code in the preceding warn log for the exact cause
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/openhuman/mcp/audit/store.rs:177 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/abd152175870b496. Report an issue: GitHub.