fix(mcp): propagate internal serialization errors instead of silently swallowing them to prevent LLM hallucination
This commit is contained in:
1 parent
f8925050db
commit
8f32a09399
13 files changed
+235
-63
No files matched your search
@@ -57,7 +57,7 @@ impl McpResource for GraphEntitiesResource {
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let graph = state_clone.graph.cache.read().unwrap();
|
||||
let data: Vec<_> = graph.entities.values().collect();
|
||||
Ok(serde_json::to_string_pretty(&data).unwrap_or_default())
|
||||
serde_json::to_string_pretty(&data).map_err(|e| e.to_string())
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -81,7 +81,7 @@ impl McpResource for GraphRelationsResource {
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let graph = state_clone.graph.cache.read().unwrap();
|
||||
let data = &graph.relations;
|
||||
Ok(serde_json::to_string_pretty(&data).unwrap_or_default())
|
||||
serde_json::to_string_pretty(&data).map_err(|e| e.to_string())
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -108,7 +108,7 @@ impl McpResource for TasksActiveResource {
|
||||
.iter()
|
||||
.filter(|t| t.status != "completed" && t.status != "done")
|
||||
.collect();
|
||||
Ok(serde_json::to_string_pretty(&data).unwrap_or_default())
|
||||
serde_json::to_string_pretty(&data).map_err(|e| e.to_string())
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -194,7 +194,7 @@ impl MemoryHandler {
|
||||
let state_clone = Arc::clone(&state);
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let items = state_clone.pinned_files.cache.read().unwrap();
|
||||
Ok(serde_json::to_string_pretty(&*items).unwrap_or_default())
|
||||
serde_json::to_string_pretty(&*items).map_err(|e| e.to_string())
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -217,7 +217,7 @@ impl MemoryHandler {
|
||||
let state_clone = Arc::clone(&state);
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let items = state_clone.milestones.cache.read().unwrap();
|
||||
Ok(serde_json::to_string_pretty(&*items).unwrap_or_default())
|
||||
serde_json::to_string_pretty(&*items).map_err(|e| e.to_string())
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
|
||||
Reference in new issue
Block a user