Bug Description
During WebDAV sync flow, provider switch destroys valid codex OAuth auth data that was just synced from the remote database.
The auth tokens are correctly synced via WebDAV into the local cc-switch DB, but the provider switch command reads the current (empty/missing) disk ~/.codex/auth.json first, then writes that empty state back into the DB, overwriting the valid synced auth.
Root Cause
The switch command executes in this order:
- Read current disk auth.json (empty because we just did a fresh sync)
- Write disk state back to DB (overwrites valid WebDAV-synced auth)
- Write config files from DB (auth is now empty)
Expected: DB auth -> disk auth.json
Actual: empty disk auth.json -> DB (destroys synced auth) -> empty auth.json
Steps to Reproduce
- Machine A: configure codex ChatGPT OAuth provider, WebDAV push
- Machine B: delete ~/.codex/auth.json
- Run cc-switch config webdav download
- Verify DB has auth via sqlite3 -- settings_config is 7601 chars with valid tokens
- Run cc-switch --app codex provider switch provider-id
- DB now shows 2603 chars -- auth was wiped
- ~/.codex/auth.json does not exist
Evidence
BEFORE provider switch: has_auth=True, settings_config_length=7601
AFTER provider switch: has_auth=False, settings_config_length=2603
Environment
- cc-switch CLI: 5.3.0
- cc-switch App (upstream): 3.12.3
- macOS 26.4 ARM64
- Node.js 25.9.0
Suggested Fix
In the provider switch flow for codex, read auth from DB first (not from disk). Only fall back to disk auth if DB auth is empty.
Related Issues
Bug Description
During WebDAV sync flow, provider switch destroys valid codex OAuth auth data that was just synced from the remote database.
The auth tokens are correctly synced via WebDAV into the local cc-switch DB, but the provider switch command reads the current (empty/missing) disk ~/.codex/auth.json first, then writes that empty state back into the DB, overwriting the valid synced auth.
Root Cause
The switch command executes in this order:
Expected: DB auth -> disk auth.json
Actual: empty disk auth.json -> DB (destroys synced auth) -> empty auth.json
Steps to Reproduce
Evidence
BEFORE provider switch: has_auth=True, settings_config_length=7601
AFTER provider switch: has_auth=False, settings_config_length=2603
Environment
Suggested Fix
In the provider switch flow for codex, read auth from DB first (not from disk). Only fall back to disk auth if DB auth is empty.
Related Issues