Skip to content

fix: toGuzzle uses getHeaders() for send-time computed auth headers#34

Merged
jwadhams merged 2 commits into
developmentfrom
fix/toGuzzle-use-getHeaders
Jul 13, 2026
Merged

fix: toGuzzle uses getHeaders() for send-time computed auth headers#34
jwadhams merged 2 commits into
developmentfrom
fix/toGuzzle-use-getHeaders

Conversation

@jwadhams

@jwadhams jwadhams commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • AbstractRequest::toGuzzle() now builds the Guzzle Request from $this->getHeaders() instead of the raw $this->headers property.
  • Documents getHeaders() as the preferred override point for headers that need to be computed at send time (e.g. pulled from secrets, or a compiled JWT), mirroring the existing getCacheTags() override pattern.

Why

Auth headers set only in __construct() go stale for AbstractUseStaleRequest background refreshes, since the refresh job clones and serializes the request before re-sending it off the queue. Overriding getHeaders() instead recomputes the header fresh every time the request is actually sent, both before and after serialization.

Test plan

  • Existing suite passes: tests/Feature/AbstractRequestTest.php, tests/Feature/AbstractUseStaleRequestTest.php, tests/Feature/LogFileTest.php (58 tests, 271 assertions)
  • CI green

🤖 Generated with Claude Code

jwadhams added 2 commits July 13, 2026 13:04
…nd-time

Requests that need an auth header pulled from secrets or a compiled JWT
couldn't set it in __construct(), since AbstractUseStaleRequest's
background refresh clones and serializes the request before re-sending
it off the queue -- construct-time state goes stale. Routing toGuzzle()
through getHeaders() lets children override that method (the same
pattern already used for getCacheTags()) to recompute headers fresh on
every send, pre- and post-serialization.
Reads cleaner than array_merge, and string-key spread is fine on this
repo's minimum supported PHP version (8.1+).
@jwadhams jwadhams merged commit b99ab10 into development Jul 13, 2026
21 checks passed
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