Repository navigation
fix(api): close upload bodies on retry preflight failures - #1136
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 15, 2026, 2:13 AM ET / 06:13 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR closes upload bodies when retry preflight fails, adds three resource-lifecycle regression cases, and documents the behavior. Merge readiness⛔ Needs changes before merge - 2 items remain The fix remains necessary on current main and v0.40.0. The resource cleanup is correct; the prior changelog feedback is only partially resolved. Priority: P2 Review scores
Verification
How this fits togetherGoogle API requests pass through a retry transport before reaching the authenticated HTTP transport. It checks the circuit breaker and prepares replayable bodies, then either returns an error or dispatches the request. flowchart TD
A[Google API request and upload body] --> B[Circuit breaker check]
B -->|Rejected| C[Close body and return error]
B -->|Allowed| D[Prepare replayable body]
D -->|Buffering fails| C
D -->|Ready or streaming| E[Authenticated HTTP transport]
E --> F[Response or retry]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep cleanup at the retry transport's pre-dispatch exits while preserving streaming ownership, replay behavior, and release-note attribution. Do we have a high-confidence way to reproduce the issue? Yes, from source: circuit rejection and buffering errors return before closing the original body on main. The added regression cases cover these paths; this review did not execute tests. Is this the best way to solve the issue? Yes. Closing rejected bodies and deferring cleanup only after buffering begins is a narrow repair that preserves streaming and replay semantics. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ae5eefa0309d. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Landed as 469b823. The shared retry transport now closes upload bodies on circuit rejection, replay-buffer read errors, and replay-buffer overflow. Dispatched streams remain owned by the underlying transport, with retry and error behavior preserved. Verification:
Proof used synthetic request bodies through Maintainer review: the changelog now references this PR. The remaining P3 request for self-credit is inapplicable because this was found during a maintainer code audit, with no external reporter or contributor. |
The Google API retry transport left upload bodies open when the circuit breaker rejected a request or retry buffering failed. Files and streams attached to those requests could remain open even after
http.Client.Doreturned an error.Close circuit-rejected bodies immediately and close consumed input bodies on every buffering exit. Dispatched streaming bodies remain owned by the underlying transport, and the original errors and retry behavior are preserved.
Validation:
http.Clientregression reproduced all three leaks before the fix: open circuit, read failure, and replay-buffer overflow each closed the body zero times.make cipassed (all Go tests, lint/deadcode, docs, generated skills, and Docker version checks).go test -race ./internal/googleapi ./internal/discoveryapi ./internal/input ./internal/timeparse ./internal/sheetsa1 ./internal/sheetsdimensionpassed.This is synthetic HTTP/resource-lifecycle proof; no live Google account or API mutation is involved. Includes an automation guide note and an Unreleased changelog entry.