Skip to content

Conversation

@imadha
Copy link

@imadha imadha commented Dec 6, 2025

Which problem is this PR solving?

When HeadersInit is passed as an array of tuples (e.g., [["Content-Type", "application/json"]]), the _addHeaders method falls through to an else branch that uses Object.assign(). This corrupts the headers into an object with numeric keys like {"0": "Content-Type", "1": "application/json"}.

Short description of the changes

Simplifies the logic by using new Headers() which correctly handles all valid HeadersInit types:

  • undefined/null
  • Headers object
  • Record<string, string>
  • Iterable<[string, string]> (including array of tuples)

Also updates an existing test to use Headers.set() API since headers are now normalized to Headers objects.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added unit tests for tuple array headers (with and without propagator)
  • All 95 existing tests pass

The _addHeaders method did not properly handle HeadersInit when passed
as an array of tuples (e.g., [["Content-Type", "application/json"]]).
The code fell through to an else branch using Object.assign(), which
corrupted the headers into an object with numeric keys.

This fix simplifies the logic by using `new Headers()` which correctly
handles all valid HeadersInit types: undefined, Headers, Record<string, string>,
and Iterable<[string, string]>.

Also updates existing test to use Headers.set() API since headers are
now always normalized to Headers objects.

Signed-off-by: Ibu Madha <[email protected]>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 6, 2025

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: imadha / name: Ibu (c783a25)

@imadha imadha marked this pull request as ready for review December 6, 2025 00:13
@imadha imadha requested a review from a team as a code owner December 6, 2025 00:13
@pichlermarc pichlermarc requested a review from a team December 6, 2025 18:34
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.

1 participant