Merge pull request #1587 from tkpdx01/fix/anthropic-credit-balance-400

fix: handle Anthropic credit balance exhausted (400) as account error
This commit is contained in:
Wesley Liddick
2026-04-12 16:42:02 +08:00
committed by GitHub

View File

@@ -142,11 +142,16 @@ func (s *RateLimitService) HandleUpstreamError(ctx context.Context, account *Acc
switch statusCode { switch statusCode {
case 400: case 400:
// 只有当错误信息包含 "organization has been disabled" 时才禁用 // "organization has been disabled" → 永久禁用
if strings.Contains(strings.ToLower(upstreamMsg), "organization has been disabled") { if strings.Contains(strings.ToLower(upstreamMsg), "organization has been disabled") {
msg := "Organization disabled (400): " + upstreamMsg msg := "Organization disabled (400): " + upstreamMsg
s.handleAuthError(ctx, account, msg) s.handleAuthError(ctx, account, msg)
shouldDisable = true shouldDisable = true
} else if account.Platform == PlatformAnthropic && strings.Contains(strings.ToLower(upstreamMsg), "credit balance") {
// Anthropic API key 余额不足(语义等同 402停止调度
msg := "Credit balance exhausted (400): " + upstreamMsg
s.handleAuthError(ctx, account, msg)
shouldDisable = true
} }
// 其他 400 错误(如参数问题)不处理,不禁用账号 // 其他 400 错误(如参数问题)不处理,不禁用账号
case 401: case 401: