From 394db3a44539b8533e0474c9677a761ab21d575c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Franco?= Date: Wed, 22 Jul 2026 12:53:56 +0200 Subject: [PATCH] Add support for guzzlehttp/psr7 3.x and Guzzle 8 exceptions. Widen PSR-7/promises constraints and resolve HTTP responses via method_exists for compatibility with Guzzle 7 and 8. --- composer.json | 4 ++-- src/Tracing/GuzzleTracingMiddleware.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 8605380ff..74696faa3 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "ext-json": "*", "ext-mbstring": "*", "ext-curl": "*", - "guzzlehttp/psr7": "^1.8.4|^2.1.1", + "guzzlehttp/psr7": "^1.8.4|^2.1.1|^3.0", "jean85/pretty-package-versions": "^1.5|^2.0.4", "psr/log": "^1.0|^2.0|^3.0", "symfony/options-resolver": "^4.4.30|^5.0.11|^6.0|^7.0|^8.0" @@ -34,7 +34,7 @@ "require-dev": { "carthage-software/mago": "1.30.0", "friendsofphp/php-cs-fixer": "^3.4", - "guzzlehttp/promises": "^2.0.3", + "guzzlehttp/promises": "^2.0.3|^3.0", "monolog/monolog": "^1.6|^2.0|^3.0", "nyholm/psr7": "^1.8", "open-telemetry/api": "^1.0", diff --git a/src/Tracing/GuzzleTracingMiddleware.php b/src/Tracing/GuzzleTracingMiddleware.php index 8e277e4c0..7b809f2f3 100644 --- a/src/Tracing/GuzzleTracingMiddleware.php +++ b/src/Tracing/GuzzleTracingMiddleware.php @@ -4,7 +4,6 @@ namespace Sentry\Tracing; -use GuzzleHttp\Exception\RequestException as GuzzleRequestException; use GuzzleHttp\Psr7\Uri; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -87,7 +86,8 @@ public static function trace(?HubInterface $hub = null): \Closure if ($responseOrException instanceof ResponseInterface) { $response = $responseOrException; - } elseif ($responseOrException instanceof GuzzleRequestException) { + } elseif (\is_object($responseOrException) && \method_exists($responseOrException, 'getResponse')) { + // Guzzle 7: RequestException::getResponse(); Guzzle 8: ResponseException::getResponse() $response = $responseOrException->getResponse(); }