Recover Codex CLI usage from prolite decode errors#719
Recover Codex CLI usage from prolite decode errors#719beginnerslvl wants to merge 2 commits intosteipete:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67a6bc2c4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return RPCRateLimitsResponse( | ||
| rateLimits: RPCRateLimitSnapshot( | ||
| primary: RPCRateLimitWindow.from(usage.rateLimit?.primaryWindow), | ||
| secondary: RPCRateLimitWindow.from(usage.rateLimit?.secondaryWindow), | ||
| credits: RPCCreditsSnapshot.from(usage.credits))) |
There was a problem hiding this comment.
Validate recovered payload before returning rate limits
recoverRateLimits returns a synthetic success whenever the error string contains any JSON body, but CodexUsageResponse has optional top-level fields so unrelated payloads like {"error":"unauthorized"} will decode and produce a snapshot with all fields nil. In that case fetchRateLimits no longer surfaces the original requestFailed error and downstream code reports UsageError.noRateLimitsFound instead, which masks auth/network failures and changes fallback/CLI exit behavior. Require at least one recovered field (primary, secondary, or credits) before returning a recovered response.
Useful? React with 👍 / 👎.
|
Thanks for the PR @beginnerslvl ! This fix is already covered and merged via #710 . |
Summary
Validation
swift run CodexUsageRecoveryHarness(temporary local verification harness, removed before commit)./.build/lint-tools/bin/swiftformat Sources Tests --lintenv DYLD_FRAMEWORK_PATH=/Library/Developer/CommandLineTools/usr/lib ./.build/lint-tools/bin/swiftlint --strictNotes
swift test --filter CodexUsageFetcherFallbackTestsis blocked in this local CLT-only environment becauseXCTestis unavailablepnpm checkis blocked on this machine becauseScripts/lint.shinvokesswiftlintwithout the requiredDYLD_FRAMEWORK_PATHCloses #717