Fatal error: Uncaught TypeError: Core\Utils\CoreHelper::serialize(): Return value must be of type ?string, false returned

I have upserted around 50000 products today and all of a sudden I got this error and I am not sure what changed. My code is the same and has worked for past few hours. Any idea what may cause this?

Fatal error: Uncaught TypeError: Core\Utils\CoreHelper::serialize(): Return value must be of type ?string, false returned in /var/www/html/libraries/vendor/apimatic/core/src/Utils/CoreHelper.php:30 Stack trace: #0 /var/www/html/libraries/vendor/apimatic/core/src/Request/Request.php(249): Core\Utils\CoreHelper::serialize() #1 /var/www/html/libraries/vendor/apimatic/core/src/Request/RequestBuilder.php(147): Core\Request\Request->setBodyFormat() #2 /var/www/html/libraries/vendor/apimatic/core/src/ApiCall.php(45): Core\Request\RequestBuilder->build() #3 /var/www/html/libraries/vendor/square/square/src/Apis/BaseApi.php(34): Core\ApiCall->execute() #4 /var/www/html/libraries/vendor/square/square/src/Apis/CatalogApi.php(132): Square\Apis\BaseApi->execute() #5 /var/www/html/_APP/square/addProductsToSquare.class.php(192): Square\Apis\CatalogApi->batchUpsertCatalogObjects() #6 /var/www/html/_APP/square/addProductsToSquare.class.php(29): addProductsToSquare->buildBatchProductUpsert() #7 /var/www/html/CONTROLLERS/square.con.php(158): addProductsToSquare->init() #8 /var/www/html/_APP/init.php(112): require('...') #9 /var/www/html/DISPATCH.php(13): include('...') #10 {main} thrown in /var/www/html/libraries/vendor/apimatic/core/src/Utils/CoreHelper.php on line 30

What request were you making that gave you this error? Also what was the request body? :slightly_smiling_face:

It was a catalog object batch upsert. I am not sure what the body looks like as it never actually makes it to square. Is there a way for me to grab it before sending it?

Before calling the serialize() method, you can add error handling to check if the data is valid. You might want to log the data or handle the false case explicitly. Or if you have control over the CoreHelper class, modify the serialize() method to handle cases where serialization fails and return null instead of false , if appropriate. :slightly_smiling_face:

I figured this out a couple of the products had a degree symbol in the name.

Thanks for sharing your findings to the community. :slightly_smiling_face: