Fix error swallowing by propagating JSON serialization errors to LLM
This commit is contained in:
1 parent
48a1973ea6
commit
01d3c22c57
6 files changed
+59
-59
No files matched your search
+26
-26
@@ -70,9 +70,9 @@ impl McpTool for QueryDecisionsHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_string(&filtered).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ impl McpTool for SearchErrorFixesHandler {
|
||||
|| contains_ignore_ascii_case(&f.solution, &q)
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_string(&filtered).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,8 +180,8 @@ impl McpTool for QueryRecentChangesHandler {
|
||||
async fn execute(&self, _args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||
let data = state
|
||||
.ledger
|
||||
.read_with(|l| serde_json::to_string(l).unwrap_or_else(|_| "[]".to_string()));
|
||||
Ok(data.to_string())
|
||||
.read_with(|l| serde_json::to_string(l).map_err(|e| e.to_string()))?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ impl McpTool for ReadPreferencesHandler {
|
||||
let data = state
|
||||
.prefs
|
||||
.read_with(|prefs| serde_json::to_string(prefs).unwrap_or_default());
|
||||
Ok(data.to_string())
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,9 +319,9 @@ impl McpTool for ListTechDebtHandler {
|
||||
d.namespace == req.namespace && (req.include_resolved || !d.is_resolved)
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_string(&filtered).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,8 +370,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
serde_json::to_value(&kg_entities).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&kg_entities).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let mut matched_tasks = std::collections::HashSet::new();
|
||||
let mut matched_snippets = std::collections::HashSet::new();
|
||||
@@ -407,8 +407,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_value(&filtered).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let snippets_json = state.snippets.read_with(|all_snippets| {
|
||||
let filtered: Vec<_> = all_snippets
|
||||
@@ -425,8 +425,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_value(&filtered).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let adrs_json = state.adrs.read_with(|all_adrs| {
|
||||
let filtered: Vec<_> = all_adrs
|
||||
@@ -445,8 +445,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_value(&filtered).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let q = req.query;
|
||||
let tech_debts_json = state.tech_debts.read_with(|debts| {
|
||||
@@ -469,8 +469,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_value(&filtered).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let memos_json = state.handoff_memos.read_with(|memos| {
|
||||
let filtered: Vec<_> = memos
|
||||
@@ -490,8 +490,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_value(&filtered).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let error_fixes_json = state.error_fixes.read_with(|fixes| {
|
||||
let filtered: Vec<_> = fixes
|
||||
@@ -501,8 +501,8 @@ impl McpTool for OmniSearchHandler {
|
||||
|| contains_ignore_ascii_case(&f.solution, &q)
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_value(&filtered).unwrap_or_default()
|
||||
});
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
let report = serde_json::json!({
|
||||
"knowledge_graph": kg_json,
|
||||
|
||||
Reference in new issue
Block a user