Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix, go): Don't send 'null' for nil request body #3987

Merged
merged 1 commit into from
Jul 4, 2024
Merged

Conversation

amckinney
Copy link
Member

This updates Go's core.Caller abstraction so that we don't send an explicit null whenever the user sets a nil request type (i.e. for POST requests). Instead, no request body is sent. An additional unit test is included in the generated core_test.go file, too.

user, err := client.Users.Create(ctx, nil) // No request body is sent.

Given that we already use the reflect package for query parameter serialization, this opts to use the simpler reflect solution to determine whether or not an interface value type is set to nil (i.e. via the new isNil helper function).

  • If this ever becomes a problem, we can instead update the generated code to include a RequestIsNil sentinel value (because the generated client code can distinguish whether or not the struct type is nil at the core.Caller call-site).

@amckinney amckinney requested a review from dsinghvi as a code owner July 4, 2024 20:13
@amckinney amckinney merged commit 1e4c6c6 into main Jul 4, 2024
22 checks passed
@amckinney amckinney deleted the amckinney/go/null branch July 4, 2024 20:22
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.

2 participants