Skip to content

fix(go): skip empty request structs when wrapper has no user-facing fields#12336

Open
tstanmay13 wants to merge 1 commit intomainfrom
devin/1771003249-fix-go-empty-request-wrapper
Open

fix(go): skip empty request structs when wrapper has no user-facing fields#12336
tstanmay13 wants to merge 1 commit intomainfrom
devin/1771003249-fix-go-empty-request-wrapper

Conversation

@tstanmay13
Copy link
Contributor

@tstanmay13 tstanmay13 commented Feb 13, 2026

Description

Refs: Slack thread

Fixes a bug where the Go SDK generator creates empty request struct parameters for GET/DELETE endpoints. This was reported by a Polytomic user who noticed Get methods taking an empty Request struct argument that's never referenced (e.g., modelsync.ExecutionsGetRequest{}).

Link to Devin run: https://app.devin.ai/sessions/33187a2cad704a4abd6dc89f64f5e1da
Requested by: @tstanmay13

Root Cause

needsRequestParameter() in sdk.go had two issues:

  1. It was unaware of service-level headers — it only checked endpoint.Headers but not the service's headers, so it couldn't account for whether service headers contributed fields to the request struct.
  2. Its default return value was true — when an SdkRequest wrapper existed but none of the explicit checks (path params, query params, headers, body) matched, it still generated a request parameter, producing an empty struct.

Why TS/Python don't have this bug: Those generators flatten wrapper properties into individual function parameters, so an empty wrapper naturally produces zero parameters. Go uses a single struct parameter, making the empty case visible.

Changes Made

  • Added serviceHeaders []*ir.HttpHeader parameter to needsRequestParameter() and shouldSkipRequestType()
  • Added len(serviceHeaders) > 0 check alongside existing len(endpoint.Headers) > 0 check
  • Changed the default return true to return false at end of needsRequestParameter() — if we've exhausted all field checks and found nothing, don't generate a request parameter
  • Threaded serviceHeaders through the full call chain: WriteClientNewGeneratedClientnewGeneratedEndpointnewEndpointSnippetgetEndpointParameters
  • Updated generators/go/sdk/versions.yml with v1.23.8

Testing

  • Seed snapshot tests (via CI) — will validate no regressions across all Go fixtures
  • No dedicated fixture added for this specific case (the empty wrapper condition depends on IR-level wrapper creation that existing fixtures don't trigger)

⚠️ Key areas for review

  1. return truereturn false (sdk.go:3903): This is the most impactful change. Verify there are no edge cases where the wrapper has meaningful fields that aren't covered by the explicit checks above (path params, query params, endpoint headers, service headers, request body).
  2. NewGeneratedClient signature change: This is an exported function — confirm no external consumers exist.
  3. len(serviceHeaders) > 0 check: Returns true for all service headers (including literal ones). This is intentional since literal headers still produce struct fields, but worth verifying this is correct behavior.

Open with Devin

…ields

Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 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 and CI monitoring

@github-actions
Copy link
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI
  • Postman

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

Copy link
Contributor

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

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 5 additional findings.

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

Development

Successfully merging this pull request may close these issues.

1 participant