Skip to content

feat: add codex oauth plan override#2808

Closed
WeilongHan wants to merge 1 commit intorouter-for-me:devfrom
WeilongHan:feat/codex-oauth-plan-override
Closed

feat: add codex oauth plan override#2808
WeilongHan wants to merge 1 commit intorouter-for-me:devfrom
WeilongHan:feat/codex-oauth-plan-override

Conversation

@WeilongHan
Copy link
Copy Markdown

No description provided.

@github-actions github-actions bot changed the base branch from main to dev April 15, 2026 08:36
@github-actions
Copy link
Copy Markdown

This pull request targeted main.

The base branch has been automatically changed to dev.

@WeilongHan WeilongHan closed this Apr 15, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to override the Codex plan type via the CODEX_OAUTH_PLAN_OVERRIDE environment variable for non-API key authentication methods. It includes a new helper function for validation and a corresponding unit test. The review feedback suggests optimizing the helper function by using sync.Once to prevent log spam from invalid environment values and ensuring the returned plan type is consistently lowercased.

Comment thread sdk/cliproxy/service.go
Comment on lines +1188 to +1200
func codexOAuthPlanOverride() string {
raw := strings.TrimSpace(os.Getenv("CODEX_OAUTH_PLAN_OVERRIDE"))
if raw == "" {
return ""
}
switch strings.ToLower(raw) {
case "free", "plus", "pro", "team", "business", "go":
return raw
default:
log.Warnf("ignoring invalid CODEX_OAUTH_PLAN_OVERRIDE value: %q", raw)
return ""
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The codexOAuthPlanOverride function is called during model registration, which can occur frequently (e.g., on every auth update or periodic refresh). Since it reads from the environment and performs validation with a potential warning log, it's better to avoid repeated log spam if an invalid value is provided. Additionally, normalizing the return value to lowercase simplifies the logic for callers and ensures consistency.

var codexOverrideWarnOnce sync.Once

func codexOAuthPlanOverride() string {
	raw := strings.TrimSpace(os.Getenv("CODEX_OAUTH_PLAN_OVERRIDE"))
	if raw == "" {
		return ""
	}
	val := strings.ToLower(raw)
	switch val {
	case "free", "plus", "pro", "team", "business", "go":
		return val
	default:
		codexOverrideWarnOnce.Do(func() {
			log.Warnf("ignoring invalid CODEX_OAUTH_PLAN_OVERRIDE value: %q", raw)
		})
		return ""
	}
}

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb8c60ece1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sdk/cliproxy/service.go
Comment on lines +882 to +885
if authKind != "apikey" {
if override := codexOAuthPlanOverride(); override != "" {
codexPlanType = override
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict plan override to OAuth auth_kind

The new override gate uses if authKind != "apikey", which treats auth_kind: "api_key" as non-API-key and applies CODEX_OAUTH_PLAN_OVERRIDE to that credential. In this codebase, api_key is a recognized account type (AccountInfo() returns "api_key"), so Codex API-key auths using that spelling can now be forced onto OAuth plan model sets whenever the env var is set. This is a regression from the “OAuth-only override” intent and can expose or hide models unexpectedly for API-key clients.

Useful? React with 👍 / 👎.

@WeilongHan WeilongHan deleted the feat/codex-oauth-plan-override branch April 15, 2026 08:45
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