Skip to content

fix(go): escape Unicode in JSON content headers - #25619

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
AndreyVMarkelov:andreymarkelov/fix-go-json-header-ascii
Nov 24, 2026
Merged

wing328 merged 1 commit into
OpenAPITools:masterfrom
AndreyVMarkelov:andreymarkelov/fix-go-json-header-ascii

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #25618

Escape non-ASCII characters and DEL in Go JSON-content header values. Supplementary Unicode characters use UTF-16 surrogate pairs. This preserves the JSON value while producing ASCII-safe headers for APIs that require them.

Ordinary headers retain their existing serialization, and JSON marshaling errors are propagated.

Tests

  • Added generated-client runtime coverage for ASCII, BMP and supplementary Unicode, DEL, existing JSON escapes, nil values, and marshaling errors. The Unicode and DEL cases failed before the fix.
  • Verified JSON and vendor JSON headers over a local HTTP request, including ordinary headers.
  • GoClientCodegenTest: 3 focused tests passed.
  • Generated the public Dropbox Files client and verified ASCII-safe header serialization and JSON round-trip.
  • Regenerated the affected Go samples; no sample changes. A Go sample without JSON-content headers also passes go test ./....

Summary by cubic

Fixes JSON-content header serialization in the Go client so non-ASCII characters and DEL are escaped as \u sequences instead of being sent raw, avoiding errors with APIs that require ASCII-safe headers.

  • Supplementary Unicode characters are emitted as UTF-16 surrogate pairs, and existing JSON escapes and marshaling errors are preserved.
  • Adds generated-client tests covering ASCII, BMP, supplementary Unicode, DEL, nil values, and marshaling errors.

Written for commit 00f6157. Summary will update on new commits.

View guided diff

@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 3 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Re-trigger cubic

@wing328

wing328 commented Nov 11, 2026

Copy link
Copy Markdown
Member

thanks for the PR

please cc the technical committee moving forward: @antihax (2017/11) @grokify (2018/07) @kemokemo (2018/09) @jirikuncar (2021/01) @ph4r5h4d (2021/04) @lwj5 (2023/04) (for Go)

ref: https://github.com/openAPITools/openapi-generator/#members-of-technical-committee

@AndreyVMarkelov

Copy link
Copy Markdown
Contributor Author

Hi @antihax @grokify, could you please take a look at this PR when you have a chance?

Would appreciate your review. Thanks!

@AndreyVMarkelov

Copy link
Copy Markdown
Contributor Author

folks, please review

"utf16.EncodeRune(r)");

try {
Process goVersion = new ProcessBuilder("go", "version").start();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please move the test to CI similar to what you did in #25089

@wing328
wing328 merged commit f3d9adc into OpenAPITools:master Nov 24, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][Go] JSON content headers contain non-ASCII characters and DEL

2 participants