[WRONG BRANCH] codex: tolerate non-string account plan values in quota and routing - #230
Closed
luvs01 wants to merge 1 commit into
Closed
[WRONG BRANCH] codex: tolerate non-string account plan values in quota and routing#230luvs01 wants to merge 1 commit into
luvs01 wants to merge 1 commit into
Conversation
|
✅ Deterministic PR hygiene checks passed. |
📝 WalkthroughWalkthroughThe change makes plan normalization tolerate non-string persisted values. Account responses preserve quota data, and usage scoring falls back to weekly quota behavior. New regression tests cover object and numeric plan values. ChangesPlan type tolerance
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
⏳ DRAFT
What to do
Its title has been prefixed with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
planwithplan?.trim()which throws whenplanis not a string, allowing malformed persisted or upstreamplanvalues to crash quota projection and routing.planvalues without changing behavior for legitimate string plans like"go"and"free".Description
isThirtyDayOnlyPlanto acceptunknownand only normalize whentypeof plan === "string", avoidingtrim()on non-strings.computeCodexUsageScoreto acceptplan?: unknownand apply the same runtime string guard before trimming and lower-casing.tests/codex-auth-api.test.tsnow includesGET /api/codex-auth/accounts tolerates a non-string persisted plan, andtests/codex-routing.test.tsaddsusage score tolerates a non-string persisted plan."go"/"free") and otherwise treat malformed plans conservatively (as unknown) so quota/routing falls back to existing safe paths.Testing
git diff --checkandbun run typecheckwith no new type errors observed.bun run test tests/codex-auth-api.test.ts tests/codex-routing.test.tsand the modified test files passed.bun run privacy:scanwhich completed successfully.bun run testexecution in this environment progressed but hit unrelated timeouts in other large suites; the targeted tests for this change were executed and passed.Codex Task
Summary by CodeRabbit
Bug Fixes
Tests