fix(proxy): 排除404状态码避免无意义重试
Some checks failed
Release Linux Build / release (push) Has been cancelled
Release Windows Build / release (push) Has been cancelled
Release MacOS Build / release (push) Has been cancelled
Build Docker Image / Build Docker Image (push) Has been cancelled

当请求资源不存在时,不代表key无效,反而可能错误地将key判断为无效,而且此时重试没有意义
This commit is contained in:
2025-08-10 13:06:25 +08:00
parent 005a8e0bd7
commit 2ab9ded58f

View File

@@ -181,7 +181,8 @@ func (ps *ProxyServer) executeRequestWithRetry(
} }
// Unified error handling for retries. // Unified error handling for retries.
if err != nil || (resp != nil && resp.StatusCode >= 400) { // Exclude 404 from being a retryable error.
if err != nil || (resp != nil && resp.StatusCode >= 400 && resp.StatusCode != http.StatusNotFound) {
if err != nil && app_errors.IsIgnorableError(err) { if err != nil && app_errors.IsIgnorableError(err) {
logrus.Debugf("Client-side ignorable error for key %s, aborting retries: %v", utils.MaskAPIKey(apiKey.KeyValue), err) logrus.Debugf("Client-side ignorable error for key %s, aborting retries: %v", utils.MaskAPIKey(apiKey.KeyValue), err)
ps.logRequest(c, group, apiKey, startTime, 499, retryCount+1, err, isStream, upstreamURL, channelHandler, bodyBytes) ps.logRequest(c, group, apiKey, startTime, 499, retryCount+1, err, isStream, upstreamURL, channelHandler, bodyBytes)