Skip to content

fix(openai): fail over passthrough 429 and 529#1391

Open
Zqysl wants to merge 1 commit intoWei-Shaw:mainfrom
Zqysl:qingyu/fix-openai-passthrough-failover-429-529
Open

fix(openai): fail over passthrough 429 and 529#1391
Zqysl wants to merge 1 commit intoWei-Shaw:mainfrom
Zqysl:qingyu/fix-openai-passthrough-failover-429-529

Conversation

@Zqysl
Copy link
Copy Markdown
Contributor

@Zqysl Zqysl commented Mar 30, 2026

Summary

  • For OpenAI accounts with extra.openai_passthrough=true, upstream 429 / 529 used to be passed straight through to the client.
  • That meant a user could still receive a direct 429 / 529 even when many other accounts were still schedulable in the pool, and the request would also be recorded in ops / SLA monitoring. That is not acceptable behavior for a multi-account gateway.
  • This patch upgrades 429 / 529 from passthrough accounts into failover-capable errors, while preserving passthrough behavior for other statuses.

说明

  • 对于开启 extra.openai_passthrough=true 的 OpenAI 账号,之前会把上游返回 429 / 529 时会直接透传给客户端。
  • 这意味着哪怕平台中还存在着大量的可调度账号,用户还是会直接收到一次 429 / 529,同时这次请求还会被记入运维监控 / SLA 统计。对于一个多账号代理平台来说,这个体验是不合理的。
  • 这次修复把passthrough账号的 429 / 529 升级为可触发 failover 的错误,保留其他状态码的passthrough特性。

修复前

image - 在仍有大量可调度账号的情况下,一个 `429` 被直接返回给用户,并且还被记录到了请求错误中。

修复后

  • 不会有此类问题发生

Testing

  • go test ./internal/service -run 'TestOpenAIGatewayService_(OAuthPassthrough|OpenAIPassthrough)|TestOpenAIWSErrorHTTPStatusFromRaw_UsageLimitReachedIs429|TestOpenAIGatewayService_SelectAccountByPreviousResponseID_(RateLimitedMiss|DBRuntimeRecheckRateLimitedMiss)'

Fumeng24 added a commit to Fumeng24/sub2api that referenced this pull request Apr 1, 2026
Cherry-picked from upstream PR Wei-Shaw#1391.
Upgrades 429/529 from passthrough accounts into failover-capable
errors instead of passing directly to client.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant