25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(ai): handle non-JSON error response in AI connection test
lexmin0412c02664778545
diff --git a/crates/dbx-core/src/ai.rs b/crates/dbx-core/src/ai.rsindex 9fdd7f7371..b0282259a6 100644--- a/crates/dbx-core/src/ai.rs+++ b/crates/dbx-core/src/ai.rs@@ -964,8 +964,20 @@ pub async fn test_connection_core(config: &AiConfig) -> Result<AiTestConnectionR.await.map_err(|e| format!("AI request failed: {e}"))?;if !res.status().is_success() {- let data: serde_json::Value = res.json().await.map_err(|e| e.to_string())?;- return Err(categorize_error(&data, config));+ let status = res.status();+ let body = res.text().await.unwrap_or_default();+ // Try JSON first (APIs like OpenAI return structured error bodies)+ if let Ok(data) = serde_json::from_str::<serde_json::Value>(&body) {+ let raw = extract_error(&data).unwrap_or_else(|| "API error".to_string());+ return Err(format!("[{}] {}", classify_error(&raw), raw));+ }+ // Non-JSON body — show HTTP status + raw body+ let msg = if body.trim().is_empty() {+ format!("HTTP {}", status)+ } else {+ format!("HTTP {}: {}", status, body.trim())+ };+ return Err(format!("[{}] {}", classify_error(&msg), msg));}res.bytes_stream()}@@ -1005,9 +1017,14 @@ fn classify_error(msg: &str) -> &'static str {"modelNotFound"} else if lower.contains("429") || lower.contains("rate limit") || lower.contains("too many requests") {"rateLimit"- } else if lower.contains("timeout") || lower.contains("timed out") {+ } else if lower.contains("timeout") || lower.contains("timed out") || lower.contains("504") {"timeout"- } else if lower.contains("connect") || lower.contains("dns") || lower.contains("resolve") {+ } else if lower.contains("connect")+ || lower.contains("dns")+ || lower.contains("resolve")+ || lower.contains("502")+ || lower.contains("503")+ {"network"} else {"unknown"