fix(go): make retry backoff context-aware and honor client-scoped WithoutRetries - #17498
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
…houtRetries Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
96550c7 to
baff212
Compare
Description
Two independent bugs in the generated Go
internal/retrier.go, reported by name.com againstfern-go-sdk1.57.1 (namedotcom/core-api-go#4, #3). Both live in the go-v2 as-is template.1. Backoff ignored the request context.
r.runusedtime.Sleep(delay). The context is only checked before each attempt, so a cancelled/expired context was noticed only after the full sleep — withRetry-Afterhonored up tomaxRetryDelay(60s), a single 429 could hold a call a minute past the caller's deadline, and Ctrl-C wired tocancel()sat in the sleep.2. Client-scoped
option.WithoutRetries()was silently dropped.NewRetrierreadattemptsout ofretryOptionsbut never storeddisabled, andRunonly consulted the per-call options — soWithoutRetries()worked per call but was a no-op on the constructor, which is exactly where you'd opt out for an API of non-idempotent writes (shouldRetryis status-only, so POSTs retry on 5xx).Retriernow persistsdisabled; a request-scopedWithMaxAttemptsstill takes precedence over it.Changes Made
generators/go-v2/base/src/asIs/internal/retrier.go_: context-awaresleepWithContexthelper;Retrier.disabledfield with request-scoped override precedence.generators/go-v2/base/src/asIs/internal/retrier_test.go_:TestRetryWaitIsInterruptedByContext,TestDisableRetries(client-scoped, request-scoped, andMaxAttemptsoverride cases).fixsummaries).seed/go-sdk/**/internal/retrier{,_test}.gosnapshots.Testing
Against
seed/go-sdk/exhaustive/no-custom-config,go test ./internal/...passes with the fix. Reverting justinternal/retrier.goto its pre-fix version (keeping the new tests) fails as expected:Link to Devin session: https://app.devin.ai/sessions/3783789dffe246c9871ebfbf25897445