Repository navigation
Commit c013987
committed
fix(codex): stop the background main refresh from retracting a reauth quarantine
`fetchMainAccountInfoWhileOwned` cleared `needsReauth` for `__main__` on every
successful `/wham/usage` response, including the periodic background refresh.
A 200 from `/wham/usage` only proves the token authenticates to the usage
endpoint. It does not prove the account can serve Responses traffic, which is a
different backend path and still answers 403 when the token's workspace can no
longer be selected — the exact condition reported in lidge-jun#327.
So when real traffic 401/403'd and `recordCodexUpstreamOutcome` quarantined the
account (routing.ts, `outcomeClass === "credential"`), the next background
refresh silently retracted that quarantine. The account went straight back into
rotation, the following request failed identically and re-marked it, and
`needsReauth` never settled — which is why the dashboard showed nothing, the
symptom lidge-jun#327 was filed about.
Gate the clear on `forceRefresh`. An explicit refresh is an operator asking to
re-evaluate, normally right after signing in again, so it stays authoritative
and lidge-jun#327's recovery path is unchanged. Sign-in and account-add still clear
unconditionally through `account-lifecycle`.
Verified on win32:
- bun run typecheck exit 0
- bun test tests/server-auth.test.ts 79 pass / 0 fail (was 78/1)
- bun test tests/codex-auth-api.test.ts 191 pass / 0 fail
- 10 adjacent auth/routing/oauth suites 325 pass / 0 fail
Mutation-checked: restoring the unconditional clear fails the new regression
test and re-fails `server-auth`'s OpenAI option auth matrix.1 parent 548e701 commit c013987
2 files changed
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
748 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
749 | 758 | | |
750 | 759 | | |
751 | 760 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
861 | 895 | | |
862 | 896 | | |
863 | 897 | | |
| |||
0 commit comments