Skip to content

fix: require OAuth accounts for Codex models manifest#3998

Open
cyeinfpro wants to merge 1 commit into
Wei-Shaw:mainfrom
cyeinfpro:agent/fix-codex-models-oauth-selection
Open

fix: require OAuth accounts for Codex models manifest#3998
cyeinfpro wants to merge 1 commit into
Wei-Shaw:mainfrom
cyeinfpro:agent/fix-codex-models-oauth-selection

Conversation

@cyeinfpro

Copy link
Copy Markdown

Summary

  • add a Codex models-specific account selector that excludes non-OAuth accounts and OAuth accounts without a resolved access token
  • preserve the existing group, priority, LRU, quota, and schedulability rules by passing the exclusions back through the normal OpenAI scheduler
  • resolve shadow accounts through their OAuth parent credentials
  • attach the selected account to the ops/access-log context
  • return a clear 503 No available OpenAI OAuth accounts response when the group has no eligible manifest account

Root cause

Requests to /v1/models?client_version=... are routed to CodexModels. The handler previously used the generic SelectAccountForModel, which can select both OAuth and API Key accounts. FetchCodexModelsManifest then requires a ChatGPT Codex OAuth access token, so selecting an API Key account produced:

{
  "error": {
    "message": "account has no Codex backend access token",
    "type": "upstream_error"
  }
}

In a mixed OAuth/API Key group, repeated model-manifest requests therefore alternated between 200 and 502 depending on the selected account.

Validation

  • go test ./internal/service -run 'Test(SelectCodexModelsAccount|FetchCodexModelsManifest)' -count=1
  • go test ./internal/service ./internal/handler ./internal/server/routes -count=1
  • go vet ./internal/service ./internal/handler ./internal/server/routes
  • go test ./... -count=1

Regression coverage includes:

  • an API Key account with a stale access_token field
  • an OAuth account with no access token
  • a valid OAuth account in the same group
  • a shadow account using its OAuth parent's credentials
  • a group with no eligible OAuth manifest account

Fixes #3995

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@cyeinfpro

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jul 10, 2026
@cyeinfpro cyeinfpro marked this pull request as ready for review July 10, 2026 14:43
@smartcmd

Copy link
Copy Markdown
Contributor

lgtm

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.

[Bug] v0.1.151: Codex /v1/models 在 OAuth/API Key 混合分组中随机 502

2 participants