feat(go): read idempotency-key generation config from the IR#17009
feat(go): read idempotency-key generation config from the IR#17009devin-ai-integration[bot] wants to merge 4 commits into
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:
|
There was a problem hiding this comment.
AI Review Summary
Ports the TS auto-generate idempotency key feature to the Go v2 SDK generator. The implementation is clean and the caller-wins precedence logic is sound. One concern: the injected key isn't captured before retries, and there's a minor consideration about idempotency semantics on PUT.
- 🔵 1 suggestion(s)
| writer.writeNewLineIfLastLineNot(); | ||
| writer.writeLine(`if headers.Get("Idempotency-Key") == "" {`); | ||
| writer.indent(); | ||
| writer.write(`headers.Set("Idempotency-Key", `); | ||
| writer.writeNode(this.context.callGenerateIdempotencyKey()); | ||
| writer.write(")"); | ||
| writer.newLine(); | ||
| writer.dedent(); | ||
| writer.writeLine("}"); |
There was a problem hiding this comment.
🔵 suggestion
The Idempotency-Key is set once on the headers bag before the request is issued, then reused across retries via the retrier (which replays the same *http.Request). That's correct — retries keep the same key, which is exactly what you want for idempotency. Just confirm the retrier doesn't rebuild the request per-attempt (from caller.go it reuses req, so this holds). No change needed, flagging for reviewer awareness.
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 |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2c38f4f to
57baf83
Compare
|
Tested the regenerated Go SDK locally through the seed harness and against an
Generated injection and commandsheaders.Set("Idempotency-Key", core.GenerateIdempotencyKey())Session: https://app.devin.ai/sessions/315ea45e9da84294a994c0e162b4eec6 |
…dempotency resolver conflict in favor of main (global api.settings support) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it. |
…helper Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
Description
Linear ticket: N/A
Read centralized
sdkConfig.idempotencyKeyGenerationfrom the IR instead of a Go generator-specific config flag. The generated Go behavior is unchanged: eligible methods receive a UUIDv4 fallback only when the caller did not provide the configured header.Changes Made
auto-generate-idempotency-keykey into the IR.@fern-fern/ir-sdk67.11.0 and regenerate the opt-in idempotency fixture.Testing
pnpm turbo run compile test --filter @fern-api/go-sdk --filter @fern-api/api-workspace-commonsgo test ./...ingenerators/gopnpm seed test --generator go-sdk --fixture idempotency-headers --local --skip-scripts --parallel 1go test ./...in both regenerated idempotency fixture outputspnpm checkLink to Devin session: https://app.devin.ai/sessions/315ea45e9da84294a994c0e162b4eec6
Requested by: @cadesark