Browse Source

fix: ali object is not iterable error need mapping to 400 error (#383)

zijiren 3 months ago
parent
commit
2bfbc84d60
1 changed files with 5 additions and 0 deletions
  1. 5 0
      core/relay/adaptor/ali/error.go

+ 5 - 0
core/relay/adaptor/ali/error.go

@@ -2,6 +2,7 @@ package ali
 
 import (
 	"net/http"
+	"strings"
 
 	"github.com/labring/aiproxy/core/relay/adaptor"
 	"github.com/labring/aiproxy/core/relay/adaptor/openai"
@@ -23,5 +24,9 @@ func ErrorHanlder(resp *http.Response) adaptor.Error {
 		openAIError.Type = relaymodel.ErrorTypeUpstream
 	}
 
+	if strings.Contains(openAIError.Message, "object is not iterable") {
+		statusCode = http.StatusBadRequest
+	}
+
 	return relaymodel.NewOpenAIError(statusCode, openAIError)
 }