fix: preserve DB auth when disk auth.json is absent during Codex provider switch#88
Merged
SaladDay merged 1 commit intoSaladDay:mainfrom Apr 5, 2026
Conversation
…ider switch When switching Codex providers, backfill_codex_current() and refresh_provider_snapshot() read auth from ~/.codex/auth.json. If the file is missing (e.g. after a WebDAV sync that only populated the DB), the code previously used None, which overwrote valid DB-synced OAuth tokens with empty data. Now both functions fall back to the existing DB snapshot's auth when the disk file is absent, so WebDAV-synced credentials survive a provider switch. Closes SaladDay#87 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
thanks!🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #87 — provider switch overwrites synced DB auth with empty disk state.
When switching Codex providers,
backfill_codex_current()andrefresh_provider_snapshot()read auth from~/.codex/auth.json. If the file is missing (e.g. after a WebDAV sync that only populated the DB), the code previously usedNone, which overwrote valid DB-synced OAuth tokens with empty data.Changes
codex.rs/backfill_codex_current(): Whenauth.jsondoesn't exist on disk, fall back tocurrent_provider.settings_config["auth"](the DB snapshot) instead ofNonemod.rs/refresh_provider_snapshot(): Same fix — whenauth.jsondoesn't exist on disk, fall back toprovider.settings_config["auth"](the DB snapshot) instead ofNoneRoot Cause
The provider switch followed a flawed execution order:
~/.codex/auth.jsonfrom disk (empty/missing after fresh WebDAV sync)Fix
Both functions now check if
auth.jsonexists on disk first (preferred, as it may be fresher). If absent, they fall back to the existing DB auth rather than usingNone. This ensures WebDAV-synced credentials survive a provider switch.Backward Compatibility
The existing test
switch_codex_succeeds_without_auth_jsonremains valid — when a provider has no auth in either disk or DB, the result is stillNone.Test plan
switch_codex_succeeds_without_auth_jsonstill passescodex_switch_removes_existing_auth_json_for_openai_official_providerstill passesauth.json, run provider switch, verify DB auth is preserved🤖 Generated with Claude Code