fix(#6425): make isTimeoutError self-contained against context errors - #6428
Conversation
Add a context.Context parameter to isTimeoutError so the function
checks ctx.Err() internally, eliminating the fragile caller obligation
documented in the previous doc comment ("Callers must check ctx.Err()
first"). This prevents the pattern from being copied incorrectly, as
happened in PR #6217 where forge.IsTransient() replicated the
Timeout() check without the caller guard.
The context parameter approach is necessary because Go's net/http
client wraps context.DeadlineExceeded in *url.Error for client
timeouts, making error-only introspection unable to distinguish
caller deadlines from transport timeouts. Checking the caller's
context disambiguates: if ctx.Err() is non-nil, the timeout reflects
caller intent (not retryable); otherwise it is a transport timeout
worth retrying.
The existing caller in do() already checks ctx.Err() before calling
isTimeoutError, so the internal guard is a no-op for current usage.
The value is structural safety for future callers.
Closes #6425
|
🤖 Finished Review · ✅ Success · Started 6:10 PM UTC · Completed 6:25 PM UTC Commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ReviewFindingsLow
|
|
🤖 Finished Retro · ✅ Success · Started 12:16 PM UTC · Completed 12:28 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Cost: $1.83 |
Retro: PR #6428 — make isTimeoutError self-contained against context errorsWorkflow performanceThe end-to-end pipeline performed well. Issue #6425 was surfaced by a retro agent analyzing PR #6217, triaged in ~5 minutes, coded in ~13 minutes, and reviewed in ~15 minutes — issue-to-PR in roughly 20 minutes. The code agent made a better technical decision than the issue proposed: it added a Timeline
FindingsMerge queue flakiness (existing issue #6179). Three of four merge queue attempts failed due to WIF provisioning rate limits. The third failure's logs confirmed: Approved-with-findings pattern (existing issue #1286). The review agent approved with two actionable test-quality findings that were never addressed: (1) a duplicate test case at lines 2966–2970 and 2990–2994 of No new proposalsThe identified improvement areas are already tracked by existing open issues. No new proposals are warranted. |
Summary
Make
isTimeoutErrorininternal/forge/github/github.goself-contained against context errors by adding acontext.Contextparameter. The function now checksctx.Err()internally instead of relying on callers to guard against context errors before calling it.Related Issue
Changes
context.Contextparameter toisTimeoutErrorso the function checksctx.Err()internallycontext.DeadlineExceededin*url.Errorfor client timeouts, making error-only introspection insufficient)do()to passctxTesting
isTimeoutErrorand its callers passisTimeoutErrorreturnsfalsewhen the caller's context is cancelled, even if the error implementsTimeout() boolgo vetand race detector report no issuesisTimeoutErrorChecklist
!for breaking changes)Closes #6425
Post-script verification
agent/6425-harden-istimeouterror)b294e1eaab74f8174dda7c556cad7e0508f6d9eb..HEAD)