Repository navigation
Support Guzzle 8 - #368
Open
wit3 wants to merge 1 commit into
Open
Support Guzzle 8#368wit3 wants to merge 1 commit into
wit3 wants to merge 1 commit into
Conversation
- Allow guzzlehttp/guzzle ^8.0 alongside ~6.0|~7.0. - Send HTTP methods uppercase: Guzzle 8 preserves the method casing it is given, so the lowercase 'get'/'post' (and the 'method' option, e.g. 'patch') would reach Salesforce verbatim. - Read the response of a failed request on every major: Guzzle 8 moves it from RequestException to ResponseException and drops hasResponse(), so assignExceptions() failed with "call to undefined method" on every 4xx/5xx, including the 401 that triggers the token refresh. - SalesforceException and TokenExpiredException keep extending RequestException and keep exposing getResponse()/hasResponse(); they store the response themselves because Guzzle 8's RequestException constructor no longer takes one (and ResponseException's is final). - Tests: build RequestException through the create() factory, which exists on both majors, and cover the request pipeline with a real Guzzle client (MockHandler + history): 401 -> refresh -> retry, error response wrapped in SalesforceException, uppercase method on the wire. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Guzzle 8.0 is out, and Laravel 13 already accepts it (
guzzlehttp/guzzle: ^7.8.2 || ^8.0). Forrest's~6.0|~7.0is now the constraint that keeps applications on Guzzle 7. Widening it isn't enough on its own, though: against Guzzle 8.2.0, unpatched master breaks in three places.Client::assignExceptions()fatals on every error response. Guzzle 8 moved the response fromRequestExceptionto the newResponseExceptionsubclass, andRequestExceptionno longer hashasResponse()/getResponse(). Every 4xx/5xx fails with "Call to undefined method", including the 401 that should trigger the token refresh.SalesforceException/TokenExpiredExceptioncan't be built. They pass$e->getResponse()as the third argument ofRequestException::__construct(), which in Guzzle 8 isint $code(TypeError).ResponseException's constructor isfinal, so extending it isn't an option.'get'/'post'(and the user-supplied'method' => 'patch'), so they would reach Salesforce verbatim.Changes
composer.json:guzzlehttp/guzzle: ~6.0|~7.0|^8.0.handleRequest(), and the literal'get'/'post'inClientand the authentication classes are now'GET'/'POST'. Nothing changes on Guzzle 6/7, which already uppercased them on the wire.Exceptions\WrapsRequestExceptiontrait, used bySalesforceExceptionandTokenExpiredException:RequestExceptionand keep their($message, RequestException $e)constructor.getResponse(): ?ResponseInterfaceandhasResponse(): bool, so catch blocks that call$e->getResponse()keep working on both majors.class_exists(ResponseException::class).assignExceptions()reads the response throughWrapsRequestException::responseFrom(), which handles both shapes.Tests
TestCase::requestException()usesRequestException::create(), which exists on both majors.ClientTestdrive a realGuzzleHttp\Client(MockHandler + history middleware) instead of a mockedClientInterface. The mocked tests never reach Guzzle's request pipeline, which is why 45/46 of them still passed on Guzzle 8 while the library was broken. The new tests cover:GETon both requests;SalesforceExceptionwithgetResponse(),hasResponse(),getCode(), the message andgetPrevious();'method' => 'patch'sent asPATCH.Local runs on PHP 8.5:
No workflow change is needed: the existing matrix already resolves Guzzle 7 on Laravel 11/12 (
^7.8.2) and Guzzle 8 on Laravel 13.Not covered here:
UserPasswordSoaphas no test that goes through a real client. Its only change is'post'→'POST'.