fix(go): fix Go client to normalize request header keys using Header.Set - #24766
Open
Wuchieh wants to merge 3 commits into
Open
fix(go): fix Go client to normalize request header keys using Header.Set#24766Wuchieh wants to merge 3 commits into
Wuchieh wants to merge 3 commits into
Conversation
- Use Set when writing headerParams to http.Header to automatically apply canonical key formatting. - Avoid inconsistent casing or duplicate header issues caused by direct map assignment.
Author
|
@lwj5 Please review it. |
Member
Member
|
please review the build failures when you've time, e.g. https://github.com/OpenAPITools/openapi-generator/actions/runs/32814668511/job/97700780542?pr=24766 |
Author
Okay, I'll take a look later to see what the issue is. |
…templates - Update the go.mod Go version format for multiple Go client/server templates (e.g., 1.23 → 1.23.0, 1.25 → 1.25.0). - Add missing terraform-plugin-testing checksums to the Terraform templates' go.sum. - Sync checksums for indirect dependencies such as testify, x/sys, and x/text. - Add go.sum files for templates including echo-server, chi-server, and gin-api-server-interface-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
http.Header.Setwhen writingheaderParamstohttp.Headerin the generated Go client.Previously, generated code directly assigned values to the underlying
http.Headermap:This bypasses the header name canonicalization provided by
http.Header.Setand may result in inconsistent header casing or duplicate logical headers.This change replaces direct map assignment with:
Changes
http.Header.Setwhen writingheaderParamstohttp.Header.Related Issue
Fixes #24765
PR checklist
Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
Run the following to [build the project](https://github.com/openapitools/openapi-generator#14---build-projects) and update samples:
If your PR is targeting a particular programming language, @mention the relevant [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members.
Summary by cubic
Normalizes request header keys in generated Go clients by using
http.Header.Setinstead of direct map assignment; previouslyheaders[h] = []string{v}wrote non-canonical names, nowheaders.Set(h, v)canonicalizes and de-duplicates.headerParamsincludes case-variant duplicates, only one canonical header is sent; which value wins depends on map iteration order.modules/openapi-generator/src/main/resources/go/client.mustacheand regenerated Go sample clients to reflect the change.Written for commit 8265451. Summary will update on new commits.