Skip to content

v0.2.2 fails to load legacy accounts.json ChatGPT auth type spelling #58

Description

@122yjs

Summary

After updating to v0.2.2, Codex Switcher can fail to load an existing ~/.codex-switcher/accounts.json with:

Failed to load accounts
Failed to parse accounts file: /Users/<user>/.codex-switcher/accounts.json

The file can still be valid JSON. The failure appears to happen when older stored accounts use a legacy ChatGPT auth type spelling such as chat_g_pt.

Expected behavior

Existing account files created by previous versions should continue to load, or be migrated safely on startup.

Actual behavior

The app fails while loading accounts, before the UI can show the saved accounts.

Observed cause

In v0.2.2, AuthMode and AuthData use #[serde(rename_all = "snake_case")]:

  • AuthMode::ChatGPT expects chat_g_p_t
  • AuthData::ChatGPT expects type: "chat_g_p_t"

load_accounts() currently reads accounts.json and immediately calls serde_json::from_str::<AccountsStore>(), so a legacy enum spelling causes the whole account store to fail parsing.

Example legacy values that can fail:

{
  "auth_mode": "chat_g_pt",
  "auth_data": {
    "type": "chat_g_pt"
  }
}

Suggested fix

Accept legacy ChatGPT spellings during deserialization, then continue serializing to the current canonical value.

For example, aliases could cover known spellings like:

  • chat_gpt
  • chatgpt
  • chat_g_pt
  • chat_g_p_t

A small regression test around AccountsStore / AuthMode / AuthData deserialization would lock this behavior.

Workaround

Back up ~/.codex-switcher/accounts.json, then update legacy account entries to the current spelling:

"auth_mode": "chat_g_p_t"

and:

"auth_data": {
  "type": "chat_g_p_t"
}

After that, v0.2.2 loads the accounts again.

Notes

This is separate from the auto-switch feature work in #42. That PR contained a compatibility-oriented change, but this issue is only about preserving/migrating existing account files after update.

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