fix(growth): 审计修复 — CRITICAL 编译错误 + LOW 静默数据丢失
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- 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,避免静默存空数据
This commit is contained in:
iven
2026-04-18 23:30:58 +08:00
parent 1595290db2
commit ab4d06c4d6
2 changed files with 15 additions and 6 deletions

View File

@@ -135,8 +135,17 @@ impl FeedbackCollector {
let mut saved = 0; let mut saved = 0;
for record in self.trust_records.values() { for record in self.trust_records.values() {
let content = let content = match serde_json::to_string(record) {
serde_json::to_string(record).unwrap_or_default(); Ok(c) => c,
Err(e) => {
tracing::warn!(
"[FeedbackCollector] Failed to serialize trust record {}: {}",
record.artifact_id,
e
);
continue;
}
};
let entry = crate::types::MemoryEntry::new( let entry = crate::types::MemoryEntry::new(
"feedback", "feedback",
MemoryType::Session, MemoryType::Session,

View File

@@ -233,8 +233,8 @@ impl LlmDriverForExtraction for TauriExtractionDriver {
user_prompt: &str, user_prompt: &str,
) -> Result<String> { ) -> Result<String> {
if messages.len() < 2 { if messages.len() < 2 {
return Err(zclaw_types::Error::msg( return Err(zclaw_types::ZclawError::InvalidInput(
"Too few messages for combined extraction", "Too few messages for combined extraction".to_string(),
)); ));
} }
@@ -276,8 +276,8 @@ impl LlmDriverForExtraction for TauriExtractionDriver {
.join(""); .join("");
if response_text.is_empty() { if response_text.is_empty() {
return Err(zclaw_types::Error::msg( return Err(zclaw_types::ZclawError::LlmError(
"Empty response from LLM for combined extraction", "Empty response from LLM for combined extraction".to_string(),
)); ));
} }