HubSpot / hubspot-api-php

HubSpot API PHP Client Libraries for V3 version of the API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GuzzleHttp\Exception\RequestException, TypeError given

michaelschuetz opened this issue · comments

Hi,

we do get this exception:

[2023-07-10 04:36:47] production.ERROR: HubSpot\RetryMiddlewareFactory::HubSpot\{closure}(): Argument #4 ($exception) must be of type ?GuzzleHttp\Exception\RequestException, TypeError given, called in /data/www/hubspot.company123.de/releases/2023-06-06_114218/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php on line 99 {"exception":"[object] (TypeError(code: 0): HubSpot\\RetryMiddlewareFactory::HubSpot\\{closure}(): Argument #4 ($exception) must be of type ?GuzzleHttp\\Exception\\RequestException, TypeError given, called in /data/www/hubspot.company123.de/releases/2023-06-06_114218/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php on line 99 at /data/www/hubspot.company123.de/releases/2023-06-06_114218/vendor/hubspot/api-client/lib/RetryMiddlewareFactory.php:89)
[stacktrace]

--> ​https://github.com/HubSpot/hubspot-api-php/blob/master/lib/RetryMiddlewareFactory.php#L89

--> straigt from hubspot live
--> pls check

thx and best
Michael

Hi @michaelschuetz .
Could you share your php version, the SDK version and guzzle version , please?

"php": "8.2",
"guzzlehttp/guzzle": "7.7",
"hubspot/api-client": "10.1",

Thx,
Michael

I've just checked it one more time and I can't reproduce it.
Workable sample app
Maybe something incorrect on your side.

I can confirm that this is an issue. You can reproduce this by breaking your DNS in a docker instance for example. Connectivity issues will also throw TypeError's resulting in failing closures in vendor/hubspot/api-client/lib/RetryMiddlewareFactory.php.

The request we used, although I don't think in our case is relevant, is vendor/hubspot/api-client/lib/Discovery/Discovery.php with ->crm()->contacts()->searchApi(); and a filter with some valid data.

Current versions:

  • php at 8.2.8
  • guzzlehttp/guzzle at 7.8.0
  • hubspot/api-client at 10.1.0

Original error thrown:
image

I hacked closures that accept all to expose the underlaying issue:
image


So, in vendor/hubspot/api-client/lib/RetryMiddlewareFactory.php the methods getRetryFunctionByRange() and getRetryFunction() gets fed a $exception argument value it doesn't like.

I've just fixed it in version 10.1.2 .