From 67556b8cbca4726d06fbe444bbdb8a1332a0a3d2 Mon Sep 17 00:00:00 2001 From: YoVinchen Date: Mon, 12 Jan 2026 21:47:53 +0800 Subject: [PATCH] test(proxy): add nested JSON error detection test for thinking rectifier --- src-tauri/src/proxy/thinking_rectifier.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src-tauri/src/proxy/thinking_rectifier.rs b/src-tauri/src/proxy/thinking_rectifier.rs index 24620d35e..731beb9c0 100644 --- a/src-tauri/src/proxy/thinking_rectifier.rs +++ b/src-tauri/src/proxy/thinking_rectifier.rs @@ -240,6 +240,16 @@ mod tests { )); } + #[test] + fn test_detect_invalid_signature_nested_json() { + // 测试嵌套 JSON 格式的错误消息(第三方渠道常见格式) + let nested_error = r#"{"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"***.content.0: Invalid `signature` in `thinking` block\"},\"request_id\":\"req_xxx\"}"}}"#; + assert!(should_rectify_thinking_signature( + Some(nested_error), + &enabled_config() + )); + } + #[test] fn test_detect_thinking_expected() { assert!(should_rectify_thinking_signature(