Skip to content

fix: preserve codex provider token during proxy sync#3723

Open
Alexlangl wants to merge 1 commit into
farion1231:mainfrom
Alexlangl:fix/codex-official-auth-preserve-proxy
Open

fix: preserve codex provider token during proxy sync#3723
Alexlangl wants to merge 1 commit into
farion1231:mainfrom
Alexlangl:fix/codex-official-auth-preserve-proxy

Conversation

@Alexlangl
Copy link
Copy Markdown
Contributor

Summary / 概述

Fix Codex proxy sync in App Enhancements mode so third-party provider tokens stored in config.toml are preserved correctly.
When Codex official auth is preserved, third-party API keys live in the active provider’s experimental_bearer_token instead of auth.json. The proxy sync path now prioritizes that provider-scoped token and filters PROXY_MANAGED per source before falling back to auth.OPENAI_API_KEY, preventing official or placeholder auth from overwriting the third-party key.

Related Issue / 关联 Issue

Fixes #3715

Screenshots / 截图

N/A, backend/proxy sync logic change only.

Before / 修改前 After / 修改后
Codex App Enhancements could sync PROXY_MANAGED or preserved official auth instead of the third-party provider token, causing third-party API failures. Codex proxy sync preserves the active provider’s experimental_bearer_token and only falls back to auth.OPENAI_API_KEY when needed.

Checklist / 检查清单

  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • cargo fmt --check passes

@farion1231
Copy link
Copy Markdown
Owner

@codex review

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: a1377b239c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let live_auth = live_config.get("auth");
let live_config_text = live_config.get("config").and_then(|v| v.as_str());
let token_from_config = live_config_text
.and_then(crate::codex_config::extract_codex_experimental_bearer_token)
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 Resolve profile-scoped Codex bearer tokens before sync

When a live Codex config is driven by profile = "..." and the profile selects the provider via [profiles.<name>].model_provider, the bearer token lives under that selected [model_providers.<id>] table; this call uses extract_codex_experimental_bearer_token, which only looks at the top-level model_provider and otherwise falls back to a top-level token. In that valid profile-only setup with OAuth/empty auth.json, sync_live_to_provider fails to backfill the current provider's auth.OPENAI_API_KEY, so enabling proxy takeover leaves the DB provider with a stale or missing key and proxy requests fail even though the live config contained the correct provider-scoped token.

Useful? React with 👍 / 👎.

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.

Codex 应用增强-切换第三方时保留官方登录的功能有bug

2 participants