From 1f76c8055310e79cb54c85ff9665c685f3596f16 Mon Sep 17 00:00:00 2001 From: JustSong Date: Mon, 29 Apr 2024 22:49:06 +0800 Subject: [PATCH] fix: fix aws claude panic (#1384) --- relay/controller/error.go | 10 ++++++++++ relay/controller/helper.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/relay/controller/error.go b/relay/controller/error.go index 69ece3ec..29d4f125 100644 --- a/relay/controller/error.go +++ b/relay/controller/error.go @@ -53,6 +53,16 @@ func (e GeneralErrorResponse) ToMessage() string { } func RelayErrorHandler(resp *http.Response) (ErrorWithStatusCode *model.ErrorWithStatusCode) { + if resp == nil { + return &model.ErrorWithStatusCode{ + StatusCode: 500, + Error: model.Error{ + Message: "resp is nil", + Type: "upstream_error", + Code: "bad_response", + }, + } + } ErrorWithStatusCode = &model.ErrorWithStatusCode{ StatusCode: resp.StatusCode, Error: model.Error{ diff --git a/relay/controller/helper.go b/relay/controller/helper.go index 2489652c..dccff486 100644 --- a/relay/controller/helper.go +++ b/relay/controller/helper.go @@ -208,6 +208,9 @@ func getMappedModelName(modelName string, mapping map[string]string) (string, bo func isErrorHappened(meta *meta.Meta, resp *http.Response) bool { if resp == nil { + if meta.ChannelType == channeltype.AwsClaude { + return false + } return true } if resp.StatusCode != http.StatusOK {