Skip to content

fix(provider-utils): pass each redirect hop an independent header snapshot - #17169

Merged
gr2m merged 2 commits into
dnukumamras/getfromapi-url-validationfrom
gr2m/guard-per-hop-header-snapshot
Jul 13, 2026
Merged

fix(provider-utils): pass each redirect hop an independent header snapshot#17169
gr2m merged 2 commits into
dnukumamras/getfromapi-url-validationfrom
gr2m/guard-per-hop-header-snapshot

Conversation

@gr2m

@gr2m gr2m commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

What this does

Follow-up to the review of #16971. fetchWithValidatedRedirects passed the same mutable Headers instance to every hop's fetch call and mutated it in place for the cross-origin credential drop. Real fetch implementations snapshot headers synchronously at call time, so observable behavior was correct — but:

  • an injected custom fetch (a supported option) that defers reading init.headers could observe post-mutation state, i.e. a first-hop request whose credentials appear already dropped or vice versa;
  • in tests, mock.calls[0][1].headers and mock.calls[1][1].headers were the same object, so any future assertion on an earlier hop's headers would silently check later-hop state.

Each hop now gets its own new Headers(currentHeaders) snapshot. Includes a regression test asserting the hops receive distinct objects and that the cross-origin drop is not retroactively visible on the first hop.

…pshot

fetchWithValidatedRedirects reused one Headers instance across hops and
mutated it in place for the cross-origin credential drop. The platform fetch
reads headers synchronously so behavior was correct, but an injected custom
fetch that defers reading could observe post-mutation state, and mock-based
tests asserting on an earlier hop would silently see later mutations. Clone
the header set per hop instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gr2m
gr2m merged commit ab60433 into dnukumamras/getfromapi-url-validation Jul 13, 2026
2 of 3 checks passed
@gr2m
gr2m deleted the gr2m/guard-per-hop-header-snapshot branch July 13, 2026 18:46
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.

2 participants