Skip to content

fix: preserve provider keys during live backfill - #1746

Open
Rat0323 wants to merge 2 commits into
BigPizzaV3:mainfrom
Rat0323:agent/preserve-pure-api-provider-key
Open

fix: preserve provider keys during live backfill#1746
Rat0323 wants to merge 2 commits into
BigPizzaV3:mainfrom
Rat0323:agent/preserve-pure-api-provider-key

Conversation

@Rat0323

@Rat0323 Rat0323 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What changed

  • keep archived Pure API auth.json credentials when the active provider editor refreshes from Codex live files
  • keep the archived provider key for official mixed API profiles while still refreshing the current official login fields
  • apply the same credential ownership rule to the automatic live-file snapshot that runs before switching providers
  • add frontend and core regression coverage for login-time key changes

Why

Codex Desktop can rewrite ~/.codex/auth.json when a user signs in with an API key. Codex++ treated that runtime file as the source of truth for the active provider in two paths:

  1. opening the active provider detail and saving it
  2. snapshotting the active provider before switching to another provider

For a Pure API profile, this could replace the provider's archived third-party key with the key entered on the Codex login screen. The snapshot path meant the overwrite could happen even without opening the provider detail.

Behavior after this change

  • Pure API: live non-credential config can still be backfilled, but the provider's archived auth/key wins
  • Official mixed API: current official login fields remain live, OPENAI_API_KEY is removed from the auth snapshot, and the archived provider key wins in experimental_bearer_token
  • Normal official login and external/manual migration behavior remain unchanged

Related context: #1204, #1531.

Validation

  • npm test — 38 passed
  • npm run check
  • cargo test -p codex-plus-core --test relay_config — 109 passed
  • cargo fmt --check

@Rat0323
Rat0323 marked this pull request as ready for review August 2, 2026 03:49
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