Skip to content

fix(generator-cli): retain Go /vN module suffix in SDK-Name header and README under --version AUTO#17039

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783971642-go-vsuffix-headers-readme
Open

fix(generator-cli): retain Go /vN module suffix in SDK-Name header and README under --version AUTO#17039
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783971642-go-vsuffix-headers-readme

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

Description

Under --version AUTO, a Go SDK is generated with the major-zero placeholder (v0.0.0-fern-placeholder), so the generator emits the module path with no /vN suffix anywhere. generator-cli retrofits the suffix afterward, but addGoMajorVersionSuffix only rewrote go.mod and import lines in .go files. It missed two other places the module path is emitted:

  • the X-Fern-SDK-Name header value — a plain (non-import) string literal: headers.Set("X-Fern-SDK-Name", "github.com/org/repo")
  • the README (README.md) — go get install command and quoted import samples (README is not a .go file, so the walk skipped it entirely)

Result for a v4 module: the header shipped as github.com/org/repo (missing /v4), the README import example didn't compile when copy-pasted, and the User-Agent (which is "<modulePath>/<version>") looked wrong (.../v4.19.0) because the name half lost its /v4.

This is distinct from #16964 (which strips /vN diff churn before FAI analysis to avoid a false breaking-change) — that fixes classification, not the shipped output format.

Changes Made

  • addGoMajorVersionSuffix now also rewrites non-import module-path string literals in .go files and Markdown docs, in addition to imports and go.mod.
  • .go files: import lines get the suffix on both the bare path and subpackage paths (unchanged); non-import lines only get the bare "<modulePath>" literal rewritten (covers X-Fern-SDK-Name). The composite User-Agent value "<modulePath>/<version>" is deliberately left alone so it doesn't become .../v4/v4.19.0.
  • New Markdown pass (README.md etc.): rewrites go get/go install commands and quoted import samples. Web URLs (e.g. https://pkg.go.dev/<modulePath>) are untouched because the module path there is neither quote-anchored nor preceded by an install command.

Pseudo-diff of the effect on a generated v4 Go SDK:

  // core/request_option.go
- headers.Set("X-Fern-SDK-Name", "github.com/org/repo")
+ headers.Set("X-Fern-SDK-Name", "github.com/org/repo/v4")
  headers.Set("User-Agent", "github.com/org/repo/v4.19.0")   // unchanged

  // README.md
- go get github.com/org/repo
+ go get github.com/org/repo/v4
- import lattice "github.com/org/repo"
+ import lattice "github.com/org/repo/v4"
  • Updated README.md generator (if applicable) — README rewriting handled in addSuffixToMarkdownFile

Testing

  • Unit tests added/updated — 3 new tests in the addGoMajorVersionSuffix suite: SDK-Name header literal gets /v4; composite User-Agent is not double-suffixed; README go get + import samples get /v4 while the pkg.go.dev badge URL is left intact.
  • Manual testing completed — full @fern-api/generator-cli suite green (452 passed, 1 skipped).

Link to Devin session: https://app.devin.ai/sessions/d7363ebb78134b23b785a4750dd9ea06
Requested by: @dvdaruri-art


Open in Devin Review

…d README under --version AUTO

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@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

The PR extends the Go /vN suffix retrofit to cover non-import string literals in .go files and Markdown docs. Logic is generally sound with quote-anchoring to avoid prefix corruption, but there's a double-suffixing risk on the bare-literal replacement for both .go and Markdown files when the path is already versioned.

  • 🟡 1 warning(s)
  • 🔵 1 suggestion(s)

Comment on lines +1234 to +1238
let updated = content
.split(`"${modulePath}/`)
.join(`"${modulePath}${suffix}/`)
.split(`"${modulePath}"`)
.join(`"${modulePath}${suffix}"`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 warning

The quoted-import replacement here has no guard against an already-suffixed path. If modulePath is github.com/org/repo and the README already contains "github.com/org/repo/v4" (or "github.com/org/repo/v4/client"), the "${modulePath}/ split will turn it into "github.com/org/repo/v4/v4/.... The go get regex uses a negative lookahead to prevent exactly this, but the quoted path handling does not. Idempotency matters if this ever runs twice or on partially-suffixed input.

Comment on lines +1185 to +1191
const newLine = isImportLine
? line
.split(`"${modulePath}/`)
.join(`"${modulePath}${suffix}/`)
.split(`"${modulePath}"`)
.join(`"${modulePath}${suffix}"`)
: line.split(`"${modulePath}"`).join(`"${modulePath}${suffix}"`);

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

Same double-suffix concern as the Markdown path: .split("${modulePath}/) on an import line that's already "<modulePath>/v4/client" produces "<modulePath>/v4/v4/client". Fine under the documented AUTO placeholder flow (always unsuffixed), but the operation isn't idempotent. Worth a lookahead-style guard or an early check for an existing /vN segment.

@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

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.

1 participant