fix: toGuzzle uses getHeaders() for send-time computed auth headers#34
Merged
Conversation
…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+).
aandrews-di
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AbstractRequest::toGuzzle()now builds the GuzzleRequestfrom$this->getHeaders()instead of the raw$this->headersproperty.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 existinggetCacheTags()override pattern.Why
Auth headers set only in
__construct()go stale forAbstractUseStaleRequestbackground refreshes, since the refresh job clones and serializes the request before re-sending it off the queue. OverridinggetHeaders()instead recomputes the header fresh every time the request is actually sent, both before and after serialization.Test plan
tests/Feature/AbstractRequestTest.php,tests/Feature/AbstractUseStaleRequestTest.php,tests/Feature/LogFileTest.php(58 tests, 271 assertions)🤖 Generated with Claude Code