From 8f88cf8e910c103c3351a7584e7a48e284e98e48 Mon Sep 17 00:00:00 2001 From: sususu Date: Sat, 14 Feb 2026 14:56:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8A=E6=B8=B8400?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E8=A2=AB=E9=94=99=E8=AF=AF=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E4=B8=BAE015/500=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit extractOriginalMessage 未处理 Anthropic 错误格式 {"error":{"message":"..."}}, 导致消息提取为空,所有上游 400 错误回退为默认的 E015 Internal server error。 - 新增 error.error?.message 路径检查 - ERROR_MATCHERS 增加 invalid.*argument 匹配 INVALID_ARGUMENT 错误 --- src/utils/errorSanitizer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/errorSanitizer.js b/src/utils/errorSanitizer.js index 02749a20..7cb927f4 100644 --- a/src/utils/errorSanitizer.js +++ b/src/utils/errorSanitizer.js @@ -56,7 +56,7 @@ const ERROR_MATCHERS = [ { pattern: /model.*not.*found|model.*unavailable|unsupported.*model/i, code: 'E006' }, // 请求错误 - { pattern: /bad.*request|invalid.*request|malformed/i, code: 'E005' }, + { pattern: /bad.*request|invalid.*request|invalid.*argument|malformed/i, code: 'E005' }, { pattern: /not.*found|404/i, code: 'E010' }, // 上游错误 @@ -158,6 +158,9 @@ function extractOriginalMessage(error) { if (error.message) { return error.message } + if (error.error?.message) { + return error.error.message + } if (error.response?.data?.error?.message) { return error.response.data.error.message }