fix(providers): bound quota response parsing - #1387
Conversation
📝 WalkthroughWalkthroughQuota responses now use a 512 KiB bounded reader with timeouts, cancellation, safety checks, and unified parse-failure handling. All provider quota probes and Cursor fallback endpoints use the reader. Tests cover oversized, stalled, malformed, and fallback responses. ChangesQuota response safety
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant QuotaProbe
participant readQuotaJson
participant ResponseBody
QuotaProbe->>readQuotaJson: Read provider quota response
readQuotaJson->>ResponseBody: Consume bounded response body
ResponseBody-->>readQuotaJson: JSON bytes or read failure
readQuotaJson-->>QuotaProbe: Parsed quota data or transient failure
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
|
|
|
Tip For best results, initiate chat on the files or code changes.
You are interacting with an AI system. |
|
All your descriptions are messed up. Please fix it @luvs01 |
|
Tip For best results, initiate chat on the files or code changes.
You are interacting with an AI system. |
Wibias
left a comment
There was a problem hiding this comment.
Reviewed current head 27d1b5f. The shared quota JSON reader bounds retained bytes at 512 KiB, adds total and inactivity deadlines, cancels oversized/stalled bodies, and converts malformed/oversized reads into the same transient null/fallback semantics used by the quota probes. Cursor fallback coverage and A6API last-good coverage exercise the important multi-probe paths, and the source guard prevents new direct Response.json quota probes. Cross-platform CI is green. No actionable correctness, security, or availability findings.
|
Thanks @luvs01! 🙏 Nice hardening pass on provider quota parsing, especially the bounded body handling and preserved fallback semantics. Merged into |
Summary
Response.json()quota probes.Verification
bun test tests/provider-quota.test.ts— 97 passed on currentdev.bun run typecheck— passed.bun run privacy:scan— passed.git diff --check origin/dev...HEAD— passed.bun run testwas attempted once. The long Windows run hit existing effective-account/catalog isolation failures and ultimately a Bun 1.3.14 panic after 1,221 seconds; no changed-path failure was observed. It was not retried.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.