fix(go): escape Unicode in JSON content headers

Merged
AN
12d ago
+136-2

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.