Skip to content

Commit bfcf398

Browse files
authored
fix(whatsapp_data): preserve anyhow cause chain in RPC error envelopes (OPENHUMAN-TAURI-6B) (tinyhumansai#1639)
1 parent 62cf335 commit bfcf398

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

  • src/openhuman/whatsapp_data

‎src/openhuman/whatsapp_data/rpc.rs‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ pub async fn whatsapp_data_ingest(req: IngestRequest) -> Result<RpcOutcome<Inges
4040
);
4141
let store = require_store()?;
4242
let result = ops::ingest(&store, req).map_err(|e| {
43-
log::warn!("[whatsapp_data][rpc] ingest error: {e}");
44-
format!("[whatsapp_data] ingest failed: {e}")
43+
// {e:#} renders the full anyhow chain — store::upsert_chats wraps
44+
// the rusqlite error with `.with_context("upsert wa_chat <jid>")`,
45+
// so plain Display ({e}) only emits the outer context and drops
46+
// the underlying SQLite cause (database locked, schema mismatch,
47+
// FK violation, …) before it reaches Sentry. See OPENHUMAN-TAURI-6B
48+
// / TAURI-B2 for the canonical instance where this masked the
49+
// real failure.
50+
log::warn!("[whatsapp_data][rpc] ingest error: {e:#}");
51+
format!("[whatsapp_data] ingest failed: {e:#}")
4552
})?;
4653
log::debug!(
4754
"[whatsapp_data][rpc] ingest ok chats={} messages={} pruned={}",
@@ -67,8 +74,8 @@ pub async fn whatsapp_data_list_chats(
6774
);
6875
let store = require_store()?;
6976
let chats = ops::list_chats(&store, req).map_err(|e| {
70-
log::warn!("[whatsapp_data][rpc] list_chats error: {e}");
71-
format!("[whatsapp_data] list_chats failed: {e}")
77+
log::warn!("[whatsapp_data][rpc] list_chats error: {e:#}");
78+
format!("[whatsapp_data] list_chats failed: {e:#}")
7279
})?;
7380
log::debug!("[whatsapp_data][rpc] list_chats ok count={}", chats.len());
7481
Ok(RpcOutcome::single_log(
@@ -87,8 +94,8 @@ pub async fn whatsapp_data_list_messages(
8794
);
8895
let store = require_store()?;
8996
let msgs = ops::list_messages(&store, req).map_err(|e| {
90-
log::warn!("[whatsapp_data][rpc] list_messages error: {e}");
91-
format!("[whatsapp_data] list_messages failed: {e}")
97+
log::warn!("[whatsapp_data][rpc] list_messages error: {e:#}");
98+
format!("[whatsapp_data] list_messages failed: {e:#}")
9299
})?;
93100
log::debug!("[whatsapp_data][rpc] list_messages ok count={}", msgs.len());
94101
Ok(RpcOutcome::single_log(
@@ -108,8 +115,8 @@ pub async fn whatsapp_data_search_messages(
108115
);
109116
let store = require_store()?;
110117
let results = ops::search_messages(&store, req).map_err(|e| {
111-
log::warn!("[whatsapp_data][rpc] search_messages error: {e}");
112-
format!("[whatsapp_data] search_messages failed: {e}")
118+
log::warn!("[whatsapp_data][rpc] search_messages error: {e:#}");
119+
format!("[whatsapp_data] search_messages failed: {e:#}")
113120
})?;
114121
log::debug!(
115122
"[whatsapp_data][rpc] search_messages ok count={}",

0 commit comments

Comments
 (0)