From ab4d06c4d61b20ce3f6f140921d0928f8fb6282d Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 18 Apr 2026 23:30:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(growth):=20=E5=AE=A1=E8=AE=A1=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20=E2=80=94=20CRITICAL=20=E7=BC=96=E8=AF=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF=20+=20LOW=20=E9=9D=99=E9=BB=98=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CRITICAL: extraction_adapter.rs extract_with_prompt() 使用不存在的 zclaw_types::Error::msg(),改为 ZclawError::InvalidInput/ZclawError::LlmError - LOW: feedback_collector.rs save() 中 serde_json::to_string().unwrap_or_default() 改为显式错误处理 + warn 日志 + continue,避免静默存空数据 --- crates/zclaw-growth/src/feedback_collector.rs | 13 +++++++++++-- .../src/intelligence/extraction_adapter.rs | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/zclaw-growth/src/feedback_collector.rs b/crates/zclaw-growth/src/feedback_collector.rs index 9b8ecaf..a0a08fa 100644 --- a/crates/zclaw-growth/src/feedback_collector.rs +++ b/crates/zclaw-growth/src/feedback_collector.rs @@ -135,8 +135,17 @@ impl FeedbackCollector { let mut saved = 0; for record in self.trust_records.values() { - let content = - serde_json::to_string(record).unwrap_or_default(); + let content = match serde_json::to_string(record) { + Ok(c) => c, + Err(e) => { + tracing::warn!( + "[FeedbackCollector] Failed to serialize trust record {}: {}", + record.artifact_id, + e + ); + continue; + } + }; let entry = crate::types::MemoryEntry::new( "feedback", MemoryType::Session, diff --git a/desktop/src-tauri/src/intelligence/extraction_adapter.rs b/desktop/src-tauri/src/intelligence/extraction_adapter.rs index e772f64..38aaeed 100644 --- a/desktop/src-tauri/src/intelligence/extraction_adapter.rs +++ b/desktop/src-tauri/src/intelligence/extraction_adapter.rs @@ -233,8 +233,8 @@ impl LlmDriverForExtraction for TauriExtractionDriver { user_prompt: &str, ) -> Result { if messages.len() < 2 { - return Err(zclaw_types::Error::msg( - "Too few messages for combined extraction", + return Err(zclaw_types::ZclawError::InvalidInput( + "Too few messages for combined extraction".to_string(), )); } @@ -276,8 +276,8 @@ impl LlmDriverForExtraction for TauriExtractionDriver { .join(""); if response_text.is_empty() { - return Err(zclaw_types::Error::msg( - "Empty response from LLM for combined extraction", + return Err(zclaw_types::ZclawError::LlmError( + "Empty response from LLM for combined extraction".to_string(), )); }