Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions generators/go/internal/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1563,12 +1563,12 @@ func generatedPackagesFromIR(ir *fernir.IntermediateRepresentation) map[string]s
}

// shouldSkipRequestType returns true if the request type should not be generated.
func shouldSkipRequestType(irEndpoint *fernir.HttpEndpoint, inlinePathParameters bool, inlineFileProperties bool) bool {
func shouldSkipRequestType(irEndpoint *fernir.HttpEndpoint, serviceHeaders []*fernir.HttpHeader, inlinePathParameters bool, inlineFileProperties bool) bool {
if irEndpoint.SdkRequest == nil || irEndpoint.SdkRequest.Shape == nil || irEndpoint.SdkRequest.Shape.Wrapper == nil {
// This endpoint doesn't have any in-lined request types that need to be generated.
return true
}
return !needsRequestParameter(irEndpoint, inlinePathParameters, inlineFileProperties)
return !needsRequestParameter(irEndpoint, serviceHeaders, inlinePathParameters, inlineFileProperties)
}

// fileUploadHasBodyProperties returns true if the file upload request has at least
Expand Down Expand Up @@ -1652,7 +1652,7 @@ func fileInfoToTypes(
for _, irService := range irServices {
subpackageFileInfo := fileInfoForType(rootPackageName, irService.Name.FernFilepath)
for _, irEndpoint := range irService.Endpoints {
if shouldSkipRequestType(irEndpoint, inlinePathParameters, inlineFileProperties) {
if shouldSkipRequestType(irEndpoint, irService.Headers, inlinePathParameters, inlineFileProperties) {
continue
}

Expand Down
18 changes: 15 additions & 3 deletions generators/go/internal/generator/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@ func (f *fileWriter) WriteClient(
f,
fernFilepath,
irEndpoints,
serviceHeaders,
rootClientInstantiation,
)
}
Expand Down Expand Up @@ -2047,6 +2048,7 @@ func NewGeneratedClient(
f *fileWriter,
fernFilepath *common.FernFilepath,
endpoints []*ir.HttpEndpoint,
serviceHeaders []*ir.HttpHeader,
rootClientInstantiation *ast.AssignStmt,
) (*GeneratedClient, error) {
var generatedEndpoints []*GeneratedEndpoint
Expand All @@ -2069,6 +2071,7 @@ func NewGeneratedClient(
fernFilepath,
rootClientInstantiation,
endpoint,
serviceHeaders,
example,
),
)
Expand All @@ -2084,6 +2087,7 @@ func newGeneratedEndpoint(
fernFilepath *common.FernFilepath,
rootClientInstantiation *ast.AssignStmt,
endpoint *ir.HttpEndpoint,
serviceHeaders []*ir.HttpHeader,
example *ir.ExampleEndpointCall,
) *GeneratedEndpoint {
return &GeneratedEndpoint{
Expand All @@ -2093,6 +2097,7 @@ func newGeneratedEndpoint(
fernFilepath,
rootClientInstantiation,
endpoint,
serviceHeaders,
example,
),
}
Expand Down Expand Up @@ -2141,13 +2146,15 @@ func newEndpointSnippet(
fernFilepath *common.FernFilepath,
rootClientInstantiation *ast.AssignStmt,
endpoint *ir.HttpEndpoint,
serviceHeaders []*ir.HttpHeader,
example *ir.ExampleEndpointCall,
) *ast.Block {
methodName := getEndpointMethodName(fernFilepath, endpoint)
parameters := getEndpointParameters(
f,
fernFilepath,
endpoint,
serviceHeaders,
example,
)
call := &ast.CallExpr{
Expand Down Expand Up @@ -2207,6 +2214,7 @@ func getEndpointParameters(
f *fileWriter,
fernFilepath *common.FernFilepath,
endpoint *ir.HttpEndpoint,
serviceHeaders []*ir.HttpHeader,
example *ir.ExampleEndpointCall,
) []ast.Expr {
var fields []*ast.Field
Expand Down Expand Up @@ -2279,7 +2287,7 @@ func getEndpointParameters(
)
}

if !shouldSkipRequestType(endpoint, f.inlinePathParameters, f.inlineFileProperties) {
if !shouldSkipRequestType(endpoint, serviceHeaders, f.inlinePathParameters, f.inlineFileProperties) {
fields = append(
fields,
exampleRequestBodyToFields(f, endpoint, example.Request)...,
Expand Down Expand Up @@ -2646,7 +2654,7 @@ func (f *fileWriter) endpointFromIR(
)

if irEndpoint.SdkRequest != nil {
if needsRequestParameter(irEndpoint, inlinePathParameters, inlineFileProperties) {
if needsRequestParameter(irEndpoint, serviceHeaders, inlinePathParameters, inlineFileProperties) {
var requestType string
requestParameterName = irEndpoint.SdkRequest.RequestParameterName.CamelCase.SafeName
if requestBody := irEndpoint.SdkRequest.Shape.JustRequestBody; requestBody != nil {
Expand Down Expand Up @@ -3867,6 +3875,7 @@ func typeReferenceFromStreamingResponse(
// function signature.
func needsRequestParameter(
endpoint *ir.HttpEndpoint,
serviceHeaders []*ir.HttpHeader,
inlinePathParameters bool,
inlineFileProperties bool,
) bool {
Expand All @@ -3882,6 +3891,9 @@ func needsRequestParameter(
if len(endpoint.Headers) > 0 {
return true
}
if len(serviceHeaders) > 0 {
return true
}
if endpoint.RequestBody != nil {
return endpoint.RequestBody.FileUpload == nil ||
fileUploadHasBodyProperties(endpoint.RequestBody.FileUpload) ||
Expand All @@ -3891,7 +3903,7 @@ func needsRequestParameter(
if onlyPathParameters != nil && *onlyPathParameters {
return false
}
return true
return false
}

// includePathParametersInWrappedRequest returns true if the endpoint's request should
Expand Down
13 changes: 13 additions & 0 deletions generators/go/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
- version: 1.23.8
changelogEntry:
- summary: |
Fix empty request structs being generated for endpoints where the SDK request wrapper
has no user-facing fields. This occurred when a wrapper was created (e.g., due to service
headers) but all fields were handled globally via RequestOptions, resulting in an empty
struct parameter in the method signature. The fix adds service header awareness to
needsRequestParameter and changes the default behavior to not generate a request parameter
when no visible fields exist.
type: fix
createdAt: "2026-02-13"
irVersion: 61

- version: 1.23.7
changelogEntry:
- summary: |
Expand Down
Loading