diff --git a/apps/ai-game-creator-shell/src-tauri/src/config.rs b/apps/ai-game-creator-shell/src-tauri/src/config.rs index e22b22158..629eb9a4f 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/config.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/config.rs @@ -4487,21 +4487,12 @@ pub(crate) async fn fetch_custom_llm_models( .await .map_err(|error| format!("无法连接模型端点:{error};请检查 API 地址和网络"))?; if !response.status().is_success() { - let status = response.status(); - let body = response - .text() - .await - .unwrap_or_else(|error| format!("响应正文读取失败:{error}")); - let detail = crate::agent::redact_agent_runtime_error( - Path::new("__agc_no_project_root__"), - body.trim(), - 600, - ); - return Err(if detail.is_empty() { - format!("模型列表读取失败(HTTP {})", status.as_u16()) - } else { - format!("模型列表读取失败(HTTP {}):{detail}", status.as_u16()) - }); + // 自定义模型端点由用户提供、响应不可信:只回报状态码,绝不回显上游正文, + // 否则会把密钥或私有数据带进错误文案。 + return Err(format!( + "模型列表读取失败(HTTP {})", + response.status().as_u16() + )); } let mut body = Vec::new(); while let Some(chunk) = response diff --git a/apps/ai-game-creator-shell/src-tauri/src/llm_catalog.rs b/apps/ai-game-creator-shell/src-tauri/src/llm_catalog.rs index 7c233a2e9..ac09f9fcd 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/llm_catalog.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/llm_catalog.rs @@ -53,9 +53,17 @@ fn parse_catalog_payload(bytes: &[u8]) -> Result { .unwrap_or("模型列表读取失败"); return Err(message.to_string()); } - return envelope - .data - .ok_or_else(|| "模型列表响应缺少 data,请稍后重试".to_string()); + return envelope.data.ok_or_else(|| { + // `ok=true` 但 `data` 为空时,把服务端协议里的 error 明细带出来, + // 否则排障只能看到笼统的「缺少 data」。 + let error_detail = envelope + .error + .as_ref() + .and_then(|error| error.message.as_deref().or(error.code.as_deref())) + .filter(|detail| !detail.trim().is_empty()) + .unwrap_or("error 字段为空"); + format!("模型列表响应缺少 data:ok=true,error={error_detail}") + }); } serde_json::from_value::(value)