Skip to content

Bug: provider switch overwrites synced DB auth with empty disk state #87

@BFlameSwift

Description

@BFlameSwift

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:

  1. Read current disk auth.json (empty because we just did a fresh sync)
  2. Write disk state back to DB (overwrites valid WebDAV-synced auth)
  3. 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

  1. Machine A: configure codex ChatGPT OAuth provider, WebDAV push
  2. Machine B: delete ~/.codex/auth.json
  3. Run cc-switch config webdav download
  4. Verify DB has auth via sqlite3 -- settings_config is 7601 chars with valid tokens
  5. Run cc-switch --app codex provider switch provider-id
  6. DB now shows 2603 chars -- auth was wiped
  7. ~/.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions