Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks 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 |
|
⏳ DRAFT
What to do
Review readiness checklist
✅ 4/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. |
리뷰 · 우선순위 70 / 80이 PR은 reset-credit consume 응답이 아직 현재 테스트 라인 수동 핸들러 502 분기 - spend가 이미 올라갔을 수 있어 ambiguous 처리가 맞다. 클라이언트가 502를 “재시도 가능한 일시 오류”로만 보이면 idempotency 키 재사용 압력이 생긴다. GUI/CLI가 이 에러를 “확인 불가, 재클릭 주의”로 보여 주는지는 이 PR 밖이지만, 메인테이너가 UX 카피까지 볼지는 선택이다. 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
…read Both consume call sites parsed the upstream answer with resp.json(), which buffers the whole body before anything checks its size. Every neighbouring reset-credit read already goes through readResetCreditJson, which short-circuits an oversized declared length, reads through the shared 64 KiB bounded reader with fatal UTF-8, and rejects a truncated or empty answer. Only these two were left unbounded. The background auto-redeemer now treats an unreadable answer the same way its sibling availability read does and raises. The manual handler marks the operation ambiguous and answers 502, because the spend may already have landed upstream while its outcome code is unreadable, and a replay of that id must never be admitted as new work.
5ba458c to
b157f78
Compare
Summary
The reset-credit consume response was the only reset-credit read still parsed with
resp.json(), which buffers the whole upstream body before anything checks its size. Both call sites did it: the background auto-redeemer increateResetCreditWhamClient, and the manualPOST /api/codex-auth/reset-credits/consumehandler.readResetCreditJsonalready exists in the same file for exactly this and is used by the availability reads on both paths. It short-circuits an oversized declaredcontent-length, reads through the shared 64 KiB bounded reader with fatal UTF-8 decoding, and rejects a truncated or empty answer. Routing the two consume reads through it removes the last unbounded buffer on this surface.The two paths differ in what an unreadable answer means. The background redeemer raises, matching how its sibling availability read already handles the same condition. The manual handler marks the operation ambiguous and answers 502: the spend may already have landed upstream while its outcome code is unreadable, so the operation must not settle and a replay of that idempotency key must not be admitted as new work. That is the same shape the existing non-OK branch already produces.
Nothing about redeem semantics, cooldown reconciliation, or the returned
remainingchanges. This bounds how much of an upstream answer is read before it is judged.Verification
bun test tests/codex-integration/codex-auth-api.test.ts: 336 pass / 0 fail on this head. With the source change reverted and the new test in place: 335 pass / 1 fail.BOUNDED_BODY_MAX_BYTESand asserts a 502 with the unconfirmed error, and that no WHAM usage refresh is issued. Before the change the oversized body is parsed,code: "reset"is accepted, and the handler answers 200 after refreshing usage.bun run typecheck,bun run structure:check,bun run privacy:scanandgit diff --checkpass.structure/providers/openai-tiers.mdnext to the manual reset-credit reconciliation rule.Note on the hygiene gate
This touches
src/codex/auth-api.ts, which.github/scripts/pr-sponsored-surface.cjslists as a restricted authentication surface, soPR hygienewill reportunsponsored_surface. The change adds no authentication or credential logic: it replaces tworesp.json()calls with the bounded reader already used elsewhere in the same file, and adds one fail-closed branch. Could a maintainer review it and applymaintainer-sponsoredif it looks right?Checklist
Review readiness evidence
Published head:
b157f784914e2cf7f4b1cf2536158c43b41b97ba, rebased once ontoc66709f31. At this verification it is six commits behind the fixed dev snapshot43f4450a5, within the gate's tolerance. The rebase range-diff is unchanged and the source/test files are byte-identical to the previous tested patch. The 336 focused auth-api passes and 335-pass/1-fail negative control were run on the earlier patch head; they were not rerun or mislabeled as a new-head run. Typecheck, structure:check, privacy:scan and diff checks passed on the published head.Exact-head Cross-platform CI 34808117806 has completed. All four Linux shards, both normal macOS shards, macOS control, static gates, storage/API, packaging/smoke and all three keyring jobs passed. Windows 1/2/3/6 passed. Windows 4/6 failed the nine desktop-restart cases addressed by #4564. Windows 5/6 failed the TOML catalog-path assertion addressed by #4568 and a newly observed
codex-auth-context.test.tsteardown EPERM inremoveTreeWithRetry.The new EPERM is not called an already-reproduced baseline defect: its file-handle/ACL cause remains unknown. The failing case calls account refresh and guardian refresh, not either changed reset-credit consume path. Its source, the other failing fixtures and the cleanup helper have identical blobs in this patch and its base. The failure is directory removal in afterEach rather than a reset-credit assertion. Author readiness therefore uses the explicit non-PR failure exception plus the completed normal gating suites; the full matrix and aggregate remain failure, not green.
No unresolved formal or inline findings remain. Maintainer security review and
maintainer-sponsoredremain required, so this PR stays draft despite completion of the author checklist. No repeated sponsorship ping, second rebase, or duplicate matrix was started.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.