Skip to content

fix(storage): deserialize legacy ChatGPT auth mode and data variants (#58) - #196

Merged
Lampese merged 2 commits into
Lampese:mainfrom
ege-arhan:fix/issue-58-legacy-auth-mode-deserialization
Oct 15, 2026
Merged

Lampese merged 2 commits into
Lampese:mainfrom
ege-arhan:fix/issue-58-legacy-auth-mode-deserialization

Conversation

@ege-arhan

Copy link
Copy Markdown
Contributor

Summary

Fixes #58 by adding serde aliases for legacy ChatGPT enum variants in AuthMode and AuthData.

Problem

After upgrading to v0.2.2+, accounts.json files containing legacy ChatGPT enum spellings (chat_gpt, chatgpt, chat_g_pt) failed to deserialize when loaded via serde_json::from_str::<AccountsStore>(), throwing an error and rendering saved accounts inaccessible:

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

Solution

  • Added #[serde(alias = "chat_gpt", alias = "chatgpt", alias = "chat_g_pt")] to AuthMode::ChatGPT.
  • Added the matching serde aliases to AuthData::ChatGPT.
  • New entries continue to serialize cleanly to canonical snake_case (chat_g_p_t).
  • Added unit tests covering deserialization of all legacy spellings for both enums.

…58)

Add serde aliases for legacy ChatGPT auth enum variants (chat_gpt,
chatgpt, chat_g_pt) on AuthMode and AuthData. Prevents accounts.json
parsing failures on upgrades from older versions.
@Lampese
Lampese merged commit 2b826d2 into Lampese:main Oct 15, 2026
Lampese pushed a commit that referenced this pull request Oct 15, 2026
Adding an account preserves the current active account, live auth.json and usage timestamps. Activation remains an explicit account-switch operation, including when adding the first account.

Add isolated command-level OAuth regression coverage. Validation: the four OAuth scenarios pass; restoring the old behavior reproduces three failures. The combined #196/#153 integration on current main passes 61 Rust tests (1 ignored).

Co-authored-by: legibet <legibetpeng@gmail.com>
Co-authored-by: Jeakcey <237689947+Jeakcey@users.noreply.github.com>
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.

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

2 participants