Skip to content

fix: preserve HeadersInit in authenticating fetch - #721

Merged
bartek-gralewicz merged 2 commits into
a2aproject:mainfrom
sunruize93-cmyk:codex/fix-auth-headers-716
Sep 17, 2026
Merged

bartek-gralewicz merged 2 commits into
a2aproject:mainfrom
sunruize93-cmyk:codex/fix-auth-headers-716

Conversation

@sunruize93-cmyk

Copy link
Copy Markdown
Contributor

Description

Fixes #716.

Normalize authentication and caller headers through the native Headers API instead of spreading RequestInit.headers as a plain object. This preserves plain-object, Headers, and tuple-array inputs on both the initial request and the authentication retry.

Caller headers retain precedence over authentication-handler headers, with case-insensitive names. A fresh header collection is created for each request; neither the caller's headers nor the handler's header objects are mutated. The public API and retry flow are unchanged.

Tests

  • Added nine regression cases covering all three header representations, 401/403 challenges, refreshed authentication headers, POST body/method preservation, case-insensitive caller precedence, and input preservation.
  • Updated existing authentication tests to inspect header values through Headers, rather than assuming a plain-object representation.
  • Against upstream ce10234b3a68e34c5b605eb95aaaf1474b9397fe, the new tests produce 7 failures and 2 passes. With this fix, all nine pass.
  • npm test: 1,555 tests pass across 69 files.
  • npm run lint:ci: passes.
  • npm run build: passes (ESM, CJS, and declarations).
  • Additional local native-fetch/HTTP-server checks pass for raw Headers and tuple-array inputs, each with a 401 followed by 200, retaining caller headers, POST body, and refreshed authentication.

Validation used Node.js 22.22.3. The separately configured integration and edge suites were not run.

Checklist

  • Follow the CONTRIBUTING guide.
  • Use a Conventional Commits PR title.
  • Ensure the default tests and linter pass.
  • Update relevant documentation (helper JSDoc documents header precedence).

AI assistance: this patch and its tests were developed and checked with Codex. The test results above are local executions, not maintainer approval or independent human review.

@sunruize93-cmyk
sunruize93-cmyk requested a review from a team as a code owner September 14, 2026 05:59
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@bartek-gralewicz bartek-gralewicz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for contributing to the SDK!

@bartek-gralewicz
bartek-gralewicz merged commit f8c33fa into a2aproject:main Sep 17, 2026
17 checks passed
bartek-gralewicz added a commit that referenced this pull request Sep 18, 2026
🤖 I have created a release *beep* *boop*
---


## [1.2.0](v1.1.0...v1.2.0)
(2026-09-18)


### Features

* **server:** Introduce SettleByTaskId method
([#692](#692))
([e856bda](e856bda))


### Bug Fixes

* accept GetExtendedAgentCard JSON-RPC calls with omitted params
([#687](#687))
([047d970](047d970))
* avoid mutating caller message configuration
([#725](#725))
([e3a6428](e3a6428))
* **client:** cache the extended Agent Card only after signature
verification ([#711](#711))
([55b601c](55b601c))
* guard terminal state transitions and make cancelTask atomic
([#636](#636))
([7b87c94](7b87c94))
* preserve call context for JSON-RPC tenant requests
([#708](#708))
([ae20aca](ae20aca))
* preserve HeadersInit in authenticating fetch
([#721](#721))
([f8c33fa](f8c33fa))
* preserve historyLength=0 and reject invalid REST listTasks pageSize
([#685](#685))
([32c1865](32c1865))
* reject empty task IDs with RequestMalformedError in getTask/cancelTask
([#629](#629))
([71aae97](71aae97))
* reject invalid ListTasks status filters with RequestMalformedError
([#631](#631))
([a881fae](a881fae))
* reject missing required extensions before mutating task history
([#690](#690))
([3b4ef3f](3b4ef3f))
* reject whitespace-only taskId on sendMessage
([#689](#689))
([85227a0](85227a0))
* return 404/-32001 for missing push notification configs
([#630](#630))
([34f06e3](34f06e3))
* scope ExecutionEventBusManager by tenant and owner to match TaskStore
([#707](#707))
([69d8899](69d8899))
* stamp the resolved taskId onto sendMessage push configs
([#688](#688))
([cfb19a8](cfb19a8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Bartek Gralewicz <[email protected]>
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]: Authentication fetch wrapper drops Headers entries and corrupts tuple-array headers

2 participants