fix: prevent Cloudflare challenge from blocking usage refresh#89
fix: prevent Cloudflare challenge from blocking usage refresh#89Js2Hou wants to merge 2 commits into
Conversation
When codex is running, the accounts/check endpoint (chatgpt.com/backend-api/accounts/check/v4-2023-04-27) may be intercepted by Cloudflare's managed challenge (403), causing the entire usage refresh to fail before get_usage (wham/usage) ever executes. Changes: - Backend: detect Cloudflare challenge response and return a readable error instead of dumping the challenge HTML page - Frontend: wrap metadata refresh in try/catch so that plan-type / subscription fetch failures never block the core usage (rate-limit / credits) refresh
e63fec2 to
588e3c0
Compare
emreertunc
left a comment
There was a problem hiding this comment.
Thanks for the fix. The usage-refresh direction looks good overall, but I found two issues that should be fixed before approval:
-
cargo fmt --manifest-path src-tauri/Cargo.toml -- --checkfails onsrc-tauri/src/api/usage.rs. The newanyhow::bail!call needs to be formatted as rustfmt expects. -
The README now documents a Windows portable asset named
codex-switcher.exe, but the current Lampese release assets do not include that file. The existing release naming/versioning scheme should not be changed or broken. Please either remove the portable EXE docs for now, or add a portable asset in a way that keeps the current installer/MSI asset names and versioned release artifacts intact.
I ran pnpm build, cargo test --manifest-path src-tauri/Cargo.toml, and git diff --check; those passed.
Confirmed real-world reproduction: renewed subscription still shown as expiredI reproduced this on Windows with Codex Switcher v0.2.7. The affected ChatGPT OAuth account was not active in Codex at the time, but its stored OAuth token had refreshed, so inactivity does not appear to be the cause. Observed with the same account credentials:
This creates a confusing split: usage bars are current while the account card continues to render a persisted past date as authoritative PR #89 is useful for keeping usage refresh working, but it does not address the misleading expiry state. Suggested follow-ups:
Useful regression cases:
No account identifiers or tokens are included in this report. |
When codex is running, the accounts/check endpoint (chatgpt.com/backend-api/accounts/check/v4-2023-04-27) may be intercepted by Cloudflare's managed challenge (403), causing the entire usage refresh to fail before get_usage (wham/usage) ever executes.
Changes: