OpenAI passthrough account wrongly excluded by `model_mapping` whitelist during account selection (passthrough bypass missing in scheduler eligibility)
Summary
For an OpenAI OAuth account with auto-passthrough enabled (extra.openai_passthrough = true, "replace auth only, allow all models"), the gateway still refuses to route a model that is not listed in the account's credentials.model_mapping. The request fails account selection and the client receives:
404 Model "<model>" is not supported by any configured account in this group
even though the account can actually serve that model (a direct "test account connection" with the same model succeeds).
Root cause: the OpenAI account-selection eligibility check calls Account.IsModelSupported() directly, which enforces the model_mapping allowlist and is unaware of passthrough. A parallel model-support check does honor passthrough, so the two checks are inconsistent.
Environment
- Version: observed on
v0.1.133(+46 commits); code paths unchanged through at least0.1.164. - Account type: OpenAI OAuth (Codex/ChatGPT),
openai_passthrough = true.
Root cause (code references)
Scheduler eligibility — passthrough-blind path used for OpenAI account selection:
internal/service/openai_gateway_service.go:1329isOpenAIAccountEligibleForRequest(...)- line
1344:if requestedModel != "" && !account.IsModelSupported(requestedModel) { return false }
- line
internal/service/account.go:622func (a *Account) IsModelSupported(requestedModel string) bool- Returns
trueonly if the account has nomodel_mapping(len==0→ allow all) or the model is present in the mapping. It has no passthrough awareness.
- Returns
Parallel model-support check that does honor passthrough (inconsistent with the above):
internal/service/gateway_service.go:3801func (s *GatewayService) isModelSupportedByAccount(...)- line
3813:if account.Platform == PlatformOpenAI && account.IsOpenAIPassthroughEnabled() { return true }(bypasses the whitelist for passthrough accounts, then falls back toIsModelSupported)
- line
internal/service/account.go:1287func (a *Account) IsOpenAIPassthroughEnabled() bool
Because isOpenAIAccountEligibleForRequest uses the passthrough-blind check, a passthrough account with a non-empty model_mapping is filtered out of the candidate set for any model not in the mapping → zero candidates → ErrNoAvailableAccounts.
Steps to reproduce
- Configure an OpenAI OAuth account and enable auto-passthrough (`extra.openai_passthrough = true).
- Ensure the account has a non-empty
credentials.model_mappingthat does not include some modelMthat the account can actually serve (e.g. a newly-released model). Note: such a mapping is commonly left over from before passthrough was enabled. - Put the account in a group and, as a client of that group, request model
M, e.g.POST /responseswith{"model":"M", ...}.
Expected
The request is routed to the account (passthrough means "only replace auth, allow all models"), and M is forwarded upstream as-is.
Actual
- Account selection excludes the account:
openai.account_select_failed,error: "no available accounts",excluded_account_count: 0. - Client receives
404 Model "M" is not supported by any configured account in this group. - A direct admin "test account connection" with model
Mon the same account succeeds (it bypassesIsModelSupported), which is what makes the failure look contradictory.
Suggested fix
In isOpenAIAccountEligibleForRequest, honor passthrough before the whitelist check — either:
- short-circuit when
account.Platform == PlatformOpenAI && account.IsOpenAIPassthroughEnabled()(mirroringisModelSupportedByAccount:3813), or - route the model-support check through the passthrough-aware
isModelSupportedByAccountinstead of callingaccount.IsModelSupporteddirectly.
Workaround (for operators)
Clear credentials.model_mapping on passthrough OpenAI accounts. Note that clearing it via the admin UI may not persist (the edit form can resubmit the existing mapping); clearing it directly in the DB (credentials = credentials - 'model_mapping') and restarting the backend (to drop the cached account) is reliable