google-ads-php icon indicating copy to clipboard operation
google-ads-php copied to clipboard

JSON parsing fails when gRPC PHP Extension is enabled and REST transport is used

Open PierrickVoulet opened this issue 4 years ago • 1 comments

When C implementation of grpc is enabled in php.ini and rest transport is enabled from code ->withTransport('rest') the ConversionUploadServiceGapicClient.uploadClickConversions method fails:

#0 /home/vagrant/google-oct/app/Vendor/google/gax/src/Transport/RestTransport.php(125): Google\Protobuf\Internal\Message->mergeFromJsonString()
#1 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(204): Google\ApiCore\Transport\RestTransport->Google\ApiCore\Transport\{closure}()
#2 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler()
#3 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /home/vagrant/google-oct/app/Vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(118): GuzzleHttp\Promise\TaskQueue->run()
#5 /home/vagrant/google-oct/app/Vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(145): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute()
#7 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /home/vagrant/google-oct/app/Vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /home/vagrant/google-oct/app/Vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V8/Services/Gapic/ConversionUploadServiceGapicClient.php(302): GuzzleHttp\Promise\Promise->wait()
#12 /home/vagrant/google-oct/app/Controller/Component/GoogleAdsApiComponent.php(383): Google\Ads\GoogleAds\V8\Services\Gapic\ConversionUploadServiceGapicClient->uploadClickConversions()
#13 /home/vagrant/google-oct/app/Controller/Component/GoogleAdsApiComponent.php(129): GoogleAdsApiComponent->uploadOfflineConversion()
#14 /home/vagrant/google-oct/app/Controller/ServicesController.php(8544): GoogleAdsApiComponent->handleOfflineConversion()
#15 [internal function]: ServicesController->testGoogleAdsLib()
#16 /home/vagrant/google-oct/lib/Cake/Controller/Controller.php(499): ReflectionMethod->invokeArgs()
#17 /home/vagrant/google-oct/lib/Cake/Routing/Dispatcher.php(193): Controller->invokeAction()
#18 /home/vagrant/google-oct/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke()
#19 /home/vagrant/google-oct/app/webroot/index.php(110): Dispatcher->dispatch()
#20 {main}

Error: Error occurred during parsing: Error parsing JSON @7:87: Type was not found

Originally posted by @rpmgr in https://github.com/googleads/google-ads-php/issues/640#issuecomment-911563386

PierrickVoulet avatar Sep 02 '21 13:09 PierrickVoulet

A few other things to note:

  • A workaround is to disable the grpc PHP extension.
  • This does not seem to happen when using GoogleAdsServiceGapicClient.search.
  • This has a fairly low impact because the rest transport is typically used when grpc is unavailable (i.e. the gRPC PHP extension cannot be installed and enabled on the environment).

PierrickVoulet avatar Sep 02 '21 13:09 PierrickVoulet