fix(openai): fail over passthrough 429 and 529#1391
Open
Zqysl wants to merge 1 commit intoWei-Shaw:mainfrom
Open
fix(openai): fail over passthrough 429 and 529#1391Zqysl wants to merge 1 commit intoWei-Shaw:mainfrom
Zqysl wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
extra.openai_passthrough=true, upstream429/529used to be passed straight through to the client.429/529even 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.429/529from passthrough accounts into failover-capable errors, while preserving passthrough behavior for other statuses.说明
extra.openai_passthrough=true的 OpenAI 账号,之前会把上游返回429/529时会直接透传给客户端。429/529,同时这次请求还会被记入运维监控 / SLA 统计。对于一个多账号代理平台来说,这个体验是不合理的。429/529升级为可触发 failover 的错误,保留其他状态码的passthrough特性。修复前
修复后
Testing
go test ./internal/service -run 'TestOpenAIGatewayService_(OAuthPassthrough|OpenAIPassthrough)|TestOpenAIWSErrorHTTPStatusFromRaw_UsageLimitReachedIs429|TestOpenAIGatewayService_SelectAccountByPreviousResponseID_(RateLimitedMiss|DBRuntimeRecheckRateLimitedMiss)'