HubSpot / hubspot-api-php

HubSpot API PHP Client Libraries for V3 version of the API
Apache License 2.0
195 stars 82 forks source link

Membership API's getPage seems to have broken #323

Closed alexandre-da-costa closed 5 months ago

alexandre-da-costa commented 7 months ago

Hello! I had code that used the following to fetch the first member of a list:

HubSpotFactory::createWithAccessToken($this->user->hubspot_token->access_token)
->crm()->lists()->membershipsApi()->getPage($this->listId, limit: 1);

It was working nicely until yesterday. Today I tested and am getting an error:

ErrorException: Object of class stdClass could not be converted to int in /Users/.../Sources/.../vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php on line 445

As you can see the ObjectSerializer ends up thinking it has an int (probably the list ID) and tries to convert an object to int. From my code, it seems that this timestamp did not use to come together with the ID, because I used to to

$response->getResults()[0]

My logs and version control history indicates this was not changed since days ago, when everything was working.

To get the ID and that worked normally. My mockup tests still passes because thats how I mocked it even.

Screenshot 2024-02-23 at 16 19 09

Stack trace:

#0 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(250): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Object of class...', '/Users/alexandr...', 445)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(2, 'Object of class...', '/Users/alexandr...', 445)
#2 /Users/.../Sources/.../backend/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(445): settype(Object(stdClass), 'int')
#3 /Users/.../Sources/.../backend/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(369): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Object(stdClass), 'int', NULL)
#4 /Users/.../Sources/.../backend/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(478): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Array, 'int[]', NULL)
#5 /Users/.../Sources/.../backend/vendor/hubspot/api-client/codegen/Crm/Lists/Api/MembershipsApi.php(1346): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Object(stdClass), '\\HubSpot\\Client...', Array)
#6 /Users/.../Sources/.../backend/vendor/hubspot/api-client/codegen/Crm/Lists/Api/MembershipsApi.php(1277): HubSpot\Client\Crm\Lists\Api\MembershipsApi->getPageWithHttpInfo(10, NULL, NULL, 1)
#7 /Users/.../Sources/.../backend/app/Services/HubSpot/Objects/HubSpotList.php(77): HubSpot\Client\Crm\Lists\Api\MembershipsApi->getPage(10, NULL, NULL, 1)
#8 /Users/.../Sources/.../backend/app/Jobs/Manual/RunLocalJob.php(60): App\Services\HubSpot\Objects\HubSpotList->getFirstObjectId()
#9 /Users/.../Sources/.../backend/app/Console/Commands/RunJob.php(35): App\Jobs\Manual\RunLocalJob->handle()
#10 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\RunJob->handle()
#11 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#12 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#13 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#14 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#15 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(194): Illuminate\Container\Container->call(Array)
#16 /Users/.../Sources/.../backend/vendor/symfony/console/Command/Command.php(326): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#17 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(163): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#18 /Users/.../Sources/.../backend/vendor/symfony/console/Application.php(1096): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /Users/.../Sources/.../backend/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\RunJob), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /Users/.../Sources/.../backend/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /Users/.../Sources/.../backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(200): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /Users/.../Sources/.../backend/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 {main}
ksvirkou-hubspot commented 6 months ago

Hi @alexandre-da-costa Thank you for reporting this issue. Hubspot have changed the response of the method, I'll fix it as soon as possible. Please note this CRM Lists in beta now.

ksvirkou-hubspot commented 6 months ago

It have been fixed in the latest version of the SDK(11.1.0)