Skip to content

feat(go): read idempotency-key generation config from the IR#17009

Open
devin-ai-integration[bot] wants to merge 4 commits into
mainfrom
devin/1783698168-go-idempotency-key
Open

feat(go): read idempotency-key generation config from the IR#17009
devin-ai-integration[bot] wants to merge 4 commits into
mainfrom
devin/1783698168-go-idempotency-key

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

Linear ticket: N/A

Read centralized sdkConfig.idempotencyKeyGeneration from 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

  • Gate the UUID helper and endpoint injection from the IR's configured header name and method list.
  • Bring in the synthetic-invocation config fallback so seed threads the CLI-only auto-generate-idempotency-key key into the IR.
  • Upgrade the Go v2 packages to @fern-fern/ir-sdk 67.11.0 and regenerate the opt-in idempotency fixture.
  • Updated README.md generator (if applicable)

Testing

  • Unit tests added/updated
  • Manual testing completed
  • pnpm turbo run compile test --filter @fern-api/go-sdk --filter @fern-api/api-workspace-commons
  • go test ./... in generators/go
  • pnpm seed test --generator go-sdk --fixture idempotency-headers --local --skip-scripts --parallel 1
  • go test ./... in both regenerated idempotency fixture outputs
  • pnpm check

Link to Devin session: https://app.devin.ai/sessions/315ea45e9da84294a994c0e162b4eec6
Requested by: @cadesark


Open in Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@nitpickybot nitpickybot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +966 to +974
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("}");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-07-13T05:08:13Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
csharp-sdk square 76s (n=5) 115s (n=5) 64s -12s (-15.8%)
go-sdk square 139s (n=5) 285s (n=5) 131s -8s (-5.8%)
java-sdk square 226s (n=5) 267s (n=5) 234s +8s (+3.5%)
php-sdk square 61s (n=5) 85s (n=5) 49s -12s (-19.7%)
python-sdk square 135s (n=5) 241s (n=5) 129s -6s (-4.4%)
ruby-sdk-v2 square 94s (n=5) 124s (n=5) 83s -11s (-11.7%)
rust-sdk square 169s (n=5) 176s (n=5) 159s -10s (-5.9%)
swift-sdk square 58s (n=5) 433s (n=5) 51s -7s (-12.1%)
ts-sdk square 127s (n=5) 128s (n=5) 118s -9s (-7.1%)

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 fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-07-13T05:08:13Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-07-13 23:46 UTC

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1783698168-go-idempotency-key branch from 2c38f4f to 57baf83 Compare July 10, 2026 21:25
@devin-ai-integration devin-ai-integration Bot changed the title feat(go): auto-generate idempotency key for POST/PUT feat(go): read idempotency-key generation config from the IR Jul 10, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Tested the regenerated Go SDK locally through the seed harness and against an httptest.Server.

  • Passed: POST without a caller key sent a valid UUIDv4 Idempotency-Key.
  • Passed: declared WithIdempotencyKey("declared-key") remained unchanged.
  • Passed: generic header-bag value header-bag-key remained unchanged.
  • Passed: DELETE sent no idempotency key.
  • Passed: baseline and opt-in generated fixtures both pass go test ./....
  • Note: default seed parallelism hit an ENOTEMPTY race between the root and nested outputs; --parallel 1 passed both fixtures (2/2).

PR #17009 runtime test evidence

Generated injection and commands
headers.Set("Idempotency-Key", core.GenerateIdempotencyKey())
pnpm seed test --generator go-sdk --fixture idempotency-headers --local --skip-scripts --parallel 1
2/2 test cases passed

=== RUN   TestIdempotencyKeyRuntimeBehavior
--- PASS: TestIdempotencyKeyRuntimeBehavior (0.00s)
PASS

Session: https://app.devin.ai/sessions/315ea45e9da84294a994c0e162b4eec6

devin-ai-integration Bot and others added 2 commits July 13, 2026 17:35
…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-ai-integration

Copy link
Copy Markdown
Contributor Author

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>
@github-actions

Copy link
Copy Markdown
Contributor

Docs Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-07-13T05:08:13Z).

Fixture main PR Delta
docs 241.5s (n=5) 242.9s (35 versions) +1.4s (+0.6%)

Docs generation runs fern generate --docs --preview end-to-end against the benchmark fixture with 35 API versions (each version: markdown processing + OpenAPI-to-IR + FDR upload).
Delta is computed against the nightly baseline on main.
Baseline from nightly run(s) on main (latest: 2026-07-13T05:08:13Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-07-13 23:43 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants