fix(http): bound watch serve and OAuth callback read timeouts - #998
Conversation
gmail watch serve and the local OAuth callback listener only set ReadHeaderTimeout. Copy the Drive changes serve pattern so both servers also set ReadTimeout, IdleTimeout, and MaxHeaderBytes. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 15, 2026, 4:59 PM ET / 20:59 UTC. ClawSweeper reviewWhat this changesThe PR adds read, idle, and header-size limits to the Gmail watch and local OAuth callback HTTP listeners, with constructor-level tests. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep open: the timeout hardening addresses a source-visible gap, but the new fixed 10-second Gmail push-body deadline can reject previously accepted slow deliveries and needs compatibility proof before merge. Priority: P2 Review scores
Verification
How this fits togetherGmail watch and OAuth authorization each start a local HTTP listener. Pub/Sub push requests or browser callback requests enter these listeners before Gmail processing or OAuth token exchange continues. flowchart LR
A[Pub/Sub push request] --> B[Gmail watch listener]
C[Browser OAuth callback] --> D[OAuth callback listener]
B --> E[HTTP read and header limits]
D --> E
E --> F[Request handler]
F --> G[Watch processing or authorization result]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep bounded listener reads, but establish that the selected Gmail push deadline admits supported deliveries and rejects deliberate slow-body abuse; adjust the default if that evidence does not hold. Do we have a high-confidence way to reproduce the issue? Yes: current main sets only a header-read deadline, while the Gmail handler performs a complete body read; a post-header dribble request reaches that unbounded path from source inspection. Is this the best way to solve the issue? No: bounding reads is the right direction, but copying the Drive listener’s 10-second value is not yet shown to be safe for Gmail’s up-to-1 MiB push-body path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 45b5d766e137. LabelsLabel changes:
Label justifications:
EvidenceWhat 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
|
What Problem This Solves
gog gmail watch serveonly setReadHeaderTimeout. After headers, a client can dribble the body forever.gog drive changes servealready setsReadTimeout,IdleTimeout, andMaxHeaderBytes. The local OAuth callback server had the same gap.This PR does not change DefaultClient usage (that is #995).
Evidence
TestGmailWatchServeCmd_HTTPServerTimeoutsandTestNewOAuthCallbackServer_ReadTimeoutassertReadTimeout,ReadHeaderTimeout,IdleTimeout, andMaxHeaderBytesare non-zero.Real behavior proof
Behavior addressed: Watch-serve and OAuth callback listeners now have the same read/idle timeouts as drive-changes serve.
Real environment tested: macOS, Go from the worktree, gogcli
/tmp/oc-impl-gogcli-timeoutheadb6c463b.Exact steps or command run after this patch:
go test ./internal/cmd ./internal/googleauthEvidence after fix: tests pass.
Observed result after fix: constructed
http.Servervalues have a 10s read timeout and 30s idle timeout.What was not tested: A live Pub/Sub client that dribbles a POST body.