[codex] reconcile OpenAI admin test rate-limit state#1772
[codex] reconcile OpenAI admin test rate-limit state#1772KnowSky404 wants to merge 2 commits intoWei-Shaw:mainfrom
Conversation
|
Added another regression-test pass for the admin OpenAI account test path so the state transitions are covered more explicitly.\n\nNew test coverage now includes:\n- with codex headers -> persists rate-limit state and clears stale error state\n- with only body -> still persists rate-limit state and clears stale error state\n- on an already account -> persists rate-limit state without unnecessary error clearing\n- without any reset signal -> does not mutate runtime state\n- -> still keeps the permanent-auth-error behavior and does not mark rate-limited\n\nThis was added mainly because the production symptom is difficult to verify manually and we wanted the state reconciliation behavior locked down with focused unit tests. |
|
Added another regression-test pass for the admin OpenAI account test path so the state transitions are covered more explicitly. New test coverage now includes:
This was added mainly because the production symptom is difficult to verify manually and we wanted the state reconciliation behavior locked down with focused unit tests. |
1e0d466 to
4d0483f
Compare
What changed
429 usage_limit_reachedresults into persisted account runtime statestatus=error/ old403error message when a retest shows the account is actually rate-limited instead of forbiddenWhy
We reproduced a production state drift where some OpenAI OAuth accounts stayed persisted as:
status=errorerror_message = Access forbidden (403): account may be suspended or lack permissionsbut live admin retesting later returned
429 usage_limit_reachedinstead.That left stale
403state in the database even though the real upstream condition had already changed.Root cause
testOpenAIAccountConnectiononly persisted permanent error state for401responses.For
429, the admin test path returned the error to the caller and persisted codex snapshot headers, but it did not reuse the existing rate-limit state handling path. As a result:rate_limited_at/rate_limit_reset_atwere not updatedstatus=errorand old403error messages could remain in placeUser impact
This makes the admin UI and stored account state align better with the actual upstream result during manual retests:
403error state no longer survives when the current result is429Validation
GOCACHE=/tmp/go-build GOMODCACHE=/tmp/go-mod go test -tags=unit ./internal/service -run 'Test(AccountTestService_OpenAI|CalculateOpenAI429ResetTime|Handle429_OpenAIPersistsCodexSnapshotImmediately|RateLimitService_RecoverAccount(AfterSuccessfulTest|State))'Related issues
Fixes #1770
Fixes #1771