Skip to content

fix(go): fix Go client to normalize request header keys using Header.Set - #24766

Open
Wuchieh wants to merge 1 commit into
OpenAPITools:masterfrom
Wuchieh:master
Open

fix(go): fix Go client to normalize request header keys using Header.Set#24766
Wuchieh wants to merge 1 commit into
OpenAPITools:masterfrom
Wuchieh:master

Conversation

@Wuchieh

@Wuchieh Wuchieh commented Aug 24, 2026

Copy link
Copy Markdown

Use http.Header.Set when writing headerParams to http.Header in the generated Go client.

Previously, generated code directly assigned values to the underlying http.Header map:

headers[h] = []string{v}

This bypasses the header name canonicalization provided by http.Header.Set and may result in inconsistent header casing or duplicate logical headers.

This change replaces direct map assignment with:

headers.Set(h, v)

Changes

  • Use http.Header.Set when writing headerParams to http.Header.
  • Ensure request header names are canonicalized consistently.
  • Avoid inconsistent casing or duplicate logical headers caused by direct map assignment.
  • Add/update regression tests to cover the expected header handling behavior.

Related Issue

Fixes #24765

PR checklist


Summary by cubic

Normalizes request header keys in generated Go clients by using http.Header.Set instead of direct map assignment. This ensures canonical casing and prevents duplicate logical headers.

  • Old behavior: headers[h] = []string{v} wrote headers without canonicalizing names. New behavior: headers.Set(h, v) canonicalizes and de-duplicates.
  • If headerParams contains case-variant duplicates, only one canonical header is sent; the winning value depends on map iteration order.
  • Regenerate clients to apply the change; the update is in modules/openapi-generator/src/main/resources/go/client.mustache.

Written for commit 70b0c1e. Summary will update on new commits.

Review in cubic

- 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.
@Wuchieh

Wuchieh commented Aug 24, 2026

Copy link
Copy Markdown
Author

@lwj5 Please review it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

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.

[BUG][GO] Generated client does not use http.Header.Set for request headers

1 participant