{"record":{"id":"5f45a4684eaf941d","repo":"tinyhumansai/openhuman","slug":"failed-to-prepare-mcp-writes-list-query","errorCode":null,"errorMessage":"failed to prepare mcp_writes list query","messagePattern":"failed to prepare mcp_writes list query","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/mcp/audit/store.rs","lineNumber":168,"sourceCode":"        bound.push(Box::new(offset));\n        log::trace!(\n            \"[mcp_audit] list_writes sql={} bound_count={} limit={} offset={}\",\n            sql,\n            bound.len(),\n            limit,\n            offset\n        );\n\n        let refs = bound\n            .iter()\n            .map(|value| value.as_ref() as &dyn ToSql)\n            .collect::<Vec<_>>();\n        log::trace!(\"[mcp_audit] list_writes preparing query\");\n        let mut stmt = match conn.prepare(&sql) {\n            Ok(stmt) => stmt,\n            Err(err) => {\n                log::warn!(\"[mcp_audit] list_writes prepare failed error={err}\");\n                return Err(anyhow::Error::new(err))\n                    .context(\"failed to prepare mcp_writes list query\");\n            }\n        };\n        log::trace!(\"[mcp_audit] list_writes executing query\");\n        let mapped = match stmt.query_map(refs.as_slice(), row_to_record) {\n            Ok(mapped) => mapped,\n            Err(err) => {\n                log::warn!(\"[mcp_audit] list_writes query failed error={err}\");\n                return Err(anyhow::Error::new(err)).context(\"failed to query mcp_writes\");\n            }\n        };\n        let rows = match mapped.collect::<rusqlite::Result<Vec<_>>>() {\n            Ok(rows) => rows,\n            Err(err) => {\n                log::warn!(\"[mcp_audit] list_writes collect failed error={err}\");\n                return Err(anyhow::Error::new(err)).context(\"failed to collect mcp_writes rows\");\n            }\n        };","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/mcp/audit/store.rs#L150-L186","documentation":"The runtime could not prepare the SQL statement for the paginated mcp_writes list query (dynamic SQL assembled with bound limit/offset). Wrapped in anyhow context 'failed to prepare mcp_writes list query', it surfaces to the RPC caller. Preparation fails when the generated SQL is invalid for the schema (e.g. after a schema drift where a column the query references no longer exists) or the connection is broken. The faulting input is the dynamically composed SELECT built from filter/bound parameters.","triggerScenarios":"Thrown at src/openhuman/mcp/audit/store.rs:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the mcp_writes schema matches the query's expected columns; re-run schema init/migration","Inspect the generated SQL in the preceding trace log ([mcp_audit] list_writes sql=...) for malformed fragments from filter composition","Recreate or repair the audit database if the connection is corrupted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}