fix: skip rate limiting when custom error codes don't match upstream status
Add ShouldHandleErrorCode guard at the entry of handleGeminiUpstreamError and AntigravityGatewayService.handleUpstreamError so that accounts with custom error codes (e.g. [599]) are not rate-limited when the upstream returns a non-matching status (e.g. 429).
This commit is contained in:
@@ -2243,6 +2243,10 @@ func (s *AntigravityGatewayService) handleUpstreamError(
|
||||
requestedModel string,
|
||||
groupID int64, sessionHash string, isStickySession bool,
|
||||
) *handleModelRateLimitResult {
|
||||
// 遵守自定义错误码策略:未命中则跳过所有限流处理
|
||||
if !account.ShouldHandleErrorCode(statusCode) {
|
||||
return nil
|
||||
}
|
||||
// 模型级限流处理(优先)
|
||||
result := s.handleModelRateLimit(&handleModelRateLimitParams{
|
||||
ctx: ctx,
|
||||
|
||||
@@ -2597,6 +2597,10 @@ func asInt(v any) (int, bool) {
|
||||
}
|
||||
|
||||
func (s *GeminiMessagesCompatService) handleGeminiUpstreamError(ctx context.Context, account *Account, statusCode int, headers http.Header, body []byte) {
|
||||
// 遵守自定义错误码策略:未命中则跳过所有限流处理
|
||||
if !account.ShouldHandleErrorCode(statusCode) {
|
||||
return
|
||||
}
|
||||
if s.rateLimitService != nil && (statusCode == 401 || statusCode == 403 || statusCode == 529) {
|
||||
s.rateLimitService.HandleUpstreamError(ctx, account, statusCode, headers, body)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user