Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to download batchob results when sending verticals #331

Closed
Babis86 opened this issue Jul 19, 2017 · 7 comments
Closed

Unable to download batchob results when sending verticals #331

Babis86 opened this issue Jul 19, 2017 · 7 comments
Assignees

Comments

@Babis86
Copy link

Babis86 commented Jul 19, 2017

I'm unable to download the results of my batchjob when it contains (AdGroup) Verticals.
I get an Error from the serializer. I tried sending only the verticalId like mentioned here:
https://groups.google.com/forum/#!msg/adwords-api/OtraLyAfyC8/-hHtKR2PAwAJ
and also with the Path. Both was not working.

Operation-Array extract

array (
  0 => 
  Google\AdsApi\AdWords\v201705\cm\AdGroupOperation::__set_state(array(
     'operand' => 
    Google\AdsApi\AdWords\v201705\cm\AdGroup::__set_state(array(
       'id' => -3122,
       'campaignId' => ******,
       'campaignName' => NULL,
       'name' => 'Varilux X series</br>Moativ Msasaasaannssssdggd2',
       'status' => NULL,
       'settings' => NULL,
       'labels' => NULL,
       'forwardCompatibilityMap' => NULL,
       'biddingStrategyConfiguration' => 
      Google\AdsApi\AdWords\v201705\cm\BiddingStrategyConfiguration::__set_state(array(
         'biddingStrategyId' => NULL,
         'biddingStrategyName' => NULL,
         'biddingStrategyType' => NULL,
         'biddingStrategySource' => NULL,
         'biddingScheme' => NULL,
         'bids' => 
        array (
          0 => 
          Google\AdsApi\AdWords\v201705\cm\CpmBid::__set_state(array(
             'bid' => 
            Google\AdsApi\AdWords\v201705\cm\Money::__set_state(array(
               'microAmount' => 900000.0,
               'ComparableValueType' => NULL,
               'parameterMap' => 
              array (
                'ComparableValue.Type' => 'ComparableValueType',
              ),
            )),
             'cpmBidSource' => NULL,
             'BidsType' => NULL,
             'parameterMap' => 
            array (
              'Bids.Type' => 'BidsType',
            ),
          )),
        ),
         'targetRoasOverride' => NULL,
      )),
       'contentBidCriterionTypeGroup' => NULL,
       'baseCampaignId' => NULL,
       'baseAdGroupId' => NULL,
       'trackingUrlTemplate' => NULL,
       'urlCustomParameters' => NULL,
       'adGroupType' => NULL,
    )),
     'operator' => 'ADD',
     'OperationType' => 'AdwordsAdgroup',
     'parameterMap' => 
    array (
      'Operation.Type' => 'OperationType',
    ),
  )),
  1 => 
  Google\AdsApi\AdWords\v201705\cm\AdGroupCriterionOperation::__set_state(array(
     'operand' => 
    Google\AdsApi\AdWords\v201705\cm\BiddableAdGroupCriterion::__set_state(array(
       'userStatus' => NULL,
       'systemServingStatus' => NULL,
       'approvalStatus' => NULL,
       'disapprovalReasons' => NULL,
       'destinationUrl' => NULL,
       'firstPageCpc' => NULL,
       'topOfPageCpc' => NULL,
       'firstPositionCpc' => NULL,
       'qualityInfo' => NULL,
       'biddingStrategyConfiguration' => NULL,
       'bidModifier' => NULL,
       'finalUrls' => NULL,
       'finalMobileUrls' => NULL,
       'finalAppUrls' => NULL,
       'trackingUrlTemplate' => NULL,
       'urlCustomParameters' => NULL,
       'adGroupId' => -3122,
       'criterionUse' => NULL,
       'criterion' => 
      Google\AdsApi\AdWords\v201705\cm\Vertical::__set_state(array(
         'verticalId' => 246,
         'verticalParentId' => NULL,
         'path' => NULL,
         'id' => NULL,
         'type' => NULL,
         'CriterionType' => NULL,
         'parameterMap' => 
        array (
          'Criterion.Type' => 'CriterionType',
        ),
      )),
       'labels' => NULL,
       'forwardCompatibilityMap' => NULL,
       'baseCampaignId' => NULL,
       'baseAdGroupId' => NULL,
       'AdGroupCriterionType' => NULL,
       'parameterMap' => 
      array (
        'AdGroupCriterion.Type' => 'AdGroupCriterionType',
      ),
    )),
     'exemptionRequests' => NULL,
     'operator' => 'ADD',
     'OperationType' => 'AdwordsCriterion',
     'parameterMap' => 
    array (
      'Operation.Type' => 'OperationType',
    ),
  ))

Error

Google\AdsApi\AdWords\AdWordsNormalizer.php L188 when calling

$value = $this->serializer->denormalize(
$value, $typeHint, $format, $context); 

an Exception is thrown

In my case $typeHint is "string[]". Symfony\Component\Serializer\Serializer.php is looking then for a normalizer in function "denormalizeObject()" and finds the Symfony\Component\Serializer\Normalizer\ArrayDenormalizer.php which itself cannot find a serializer for the $type = 'string' when calling $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format); in Symfony\Component\Serializer\Normalizer\ArrayDenormalizer.php L63, is this Serializer missing?
This happens only when sending Verticals (see above Operations-Array) on version v28.0.0 (Serializer v3.0.3 & v3.3.5 tested)

[Symfony\Component\Serializer\Exception\UnexpectedValueException]
Could not denormalize object of type string[], no supporting normalizer found.

Stacktrace

Symfony\Component\Serializer\Exception\UnexpectedValueException: Could not denormalize object of type string[], no supporting normalizer found. in /var/www/dsp/vendor/symfony/serializer/Serializer.php:262 Stack trace: #0 /var/www/dsp/vendor/symfony/serializer/Serializer.php(160): Symfony\Component\Serializer\Serializer->denormalizeObject(Array, 'string[]', NULL, Array) #1 /var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php(189): Symfony\Component\Serializer\Serializer->denormalize(Array, 'string[]', NULL, Array) #2 /var/www/dsp/vendor/symfony/serializer/Serializer.php(250): Google\AdsApi\AdWords\AdWordsNormalizer->denormalize(Array, '\\Google\\AdsApi\\...', NULL, Array) #3 /var/www/dsp/vendor/symfony/serializer/Serializer.php(160): Symfony\Component\Serializer\Serializer->denormalizeObject(Array, '\\Google\\AdsApi\\...', NULL, Array) #4 /var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php(189): Symfony\Component\Serializer\Serializer->denormalize(Array, '\\Google\\AdsApi\\...', NULL, Array) #5 /var/www/dsp/vendor/symfony/serializer/Serializer.php(250): Google\AdsApi\AdWords\AdWordsNormalizer->denormalize(Array, '\\Google\\AdsApi\\...', NULL, Array) #6 /var/www/dsp/vendor/symfony/serializer/Serializer.php(160): Symfony\Component\Serializer\Serializer->denormalizeObject(Array, '\\Google\\AdsApi\\...', NULL, Array) #7 /var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php(189): Symfony\Component\Serializer\Serializer->denormalize(Array, '\\Google\\AdsApi\\...', NULL, Array) #8 /var/www/dsp/vendor/symfony/serializer/Serializer.php(250): Google\AdsApi\AdWords\AdWordsNormalizer->denormalize(Array, '\\Google\\AdsApi\\...', NULL, Array) #9 /var/www/dsp/vendor/symfony/serializer/Serializer.php(160): Symfony\Component\Serializer\Serializer->denormalizeObject(Array, '\\Google\\AdsApi\\...', NULL, Array) #10 /var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php(189): Symfony\Component\Serializer\Serializer->denormalize(Array, '\\Google\\AdsApi\\...', NULL, Array) #11 /var/www/dsp/vendor/symfony/serializer/Serializer.php(250): Google\AdsApi\AdWords\AdWordsNormalizer->denormalize(Array, 'Google\\AdsApi\\A...', NULL, Array) #12 /var/www/dsp/vendor/symfony/serializer/Serializer.php(160): Symfony\Component\Serializer\Serializer->denormalizeObject(Array, 'Google\\AdsApi\\A...', NULL, Array) #13 /var/www/dsp/vendor/symfony/serializer/Normalizer/ArrayDenormalizer.php(51): Symfony\Component\Serializer\Serializer->denormalize(Array, 'Google\\AdsApi\\A...', NULL, Array) #14 [internal function]: Symfony\Component\Serializer\Normalizer\ArrayDenormalizer->Symfony\Component\Serializer\Normalizer\{closure}(Array) #15 /var/www/dsp/vendor/symfony/serializer/Normalizer/ArrayDenormalizer.php(53): array_map(Object(Closure), Array) #16 /var/www/dsp/vendor/symfony/serializer/Serializer.php(250): Symfony\Component\Serializer\Normalizer\ArrayDenormalizer->denormalize(Array, 'Google\\AdsApi\\A...', NULL, Array) #17 /var/www/dsp/vendor/symfony/serializer/Serializer.php(160): Symfony\Component\Serializer\Serializer->denormalizeObject(Array, 'Google\\AdsApi\\A...', NULL, Array) #18 /var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/BatchJobs/v201705/BatchJobsDelegate.php(272): Symfony\Component\Serializer\Serializer->denormalize(Array, 'Google\\AdsApi\\A...') #19 /var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/BatchJobs/v201705/BatchJobs.php(124): Google\AdsApi\AdWords\BatchJobs\v201705\BatchJobsDelegate->downloadBatchJobResults('https://batch-j...') #20 /var/www/dsp/app/Adwords/AdwordsJob.php(432): Google\AdsApi\AdWords\BatchJobs\v201705\BatchJobs->downloadBatchJobResults('https://batch-j...')

Download url

https://batch-job-download-prod-ebe9b43.storage.googleapis.com/112141267/532260638.results.xml?GoogleAccessId=926043054183-rbu1gkdushnqrfcf47gser4u8qse2ig4@developer.gserviceaccount.com&Expires=1503068586&Signature=SWMz5OCb3MdRbk6MnU1lAocGIr8eM4F63GgSi3qM4Q%2FeZGxci2JZfghU6Atectpw0BqucsA13tYsoPcdFMwU%2FT%2F8f%2BUhJBHZMoptVl%2BBtcVzv7vxyzJJ6KAzpcYqORAwpwG1u%2BPK3tyz8QromqcaJGkv3TwpywvGeYrdZwVCBoJhNi2PMKXEVA1oBfZtpkJE4gThSuGSr%2F7o41pER5RPs5TEBWV10MamshvM6rmK3LohyHqMKz9tjGLpWSftuSmujrQu5NKIYLpvTeu6rtB2q7felzyPBqgAR7acRTgFYXi0UOsNWN3NRrNd1Mock5SYONNhYVB8hEQvB81e%2FTx6xg%3D%3D:
@fiboknacky
Copy link
Member

Hello,

I'll have a look deeply soon but it looks like this shouldn't be caused by VerticalId as its type hint should be just "string", not "string[]", so this might be a side effect of other things.

Is it possible for you to dump the $value that caused the error in line 188 too?

Cheers,
Knack

@Babis86
Copy link
Author

Babis86 commented Jul 20, 2017

Thanks for the fast reply

$context:
/var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php:187:
array(0) {
}

$typeHint:
/var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php:188:
string(8) "string[]"

$format:
/var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php:189:
NULL

$value:
/var/www/dsp/vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php:190:
array(2) {
  [0] =>
  string(6) "Health"
  [1] =>
  string(11) "Vision Care"
}

Best,
babis

@fiboknacky fiboknacky self-assigned this Jul 31, 2017
@sjoorm
Copy link

sjoorm commented Aug 1, 2017

Hi @fiboknacky , I have exactly the same issue, also unable to deserialise batch job result.
In my case the problem is caused by ExpandedTextAd object

vendor/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsNormalizer.php:189

$context:
array(0) {
}

$typeHint:
string(8) "string[]"

$format:
NULL

$value:
array(2) {
  [0] =>
  string(29) "http://www.intelliad.de/blog/"
  [1] =>
  string(60) "http://www.intelliad.de/kontakt/kontakt.html?time=1501589823"
}

So it is failing to deserialise/denormalise FinalMobileUrls of ExpandedTextAd. According to what @Babis86 wrote, I suppose that the problem is exactly with deserialisation of arrays which have "string[]" in PHPDoc (since PHPDoc is used to determine the object type). Maybe it will fail for other scalar types used with [] in PHPDoc as well.

Update: if it helps, here is the whole $data object of the ExpandedTextAd:
screen shot 2017-08-01 at 15 00 58

Interesting that FinalUrls has same string[] declaration in PHPDoc, but is represented by a single string instead of array in incoming data. I saw in library code that it is an expected behaviour. I think if it would have 2 FinalUrls it will fail as well.

Best,
Alexey

sjoorm added a commit to sjoorm/googleads-php-lib that referenced this issue Aug 1, 2017
Do not try to denormalize scalar types enclosed into arrays
@sjoorm
Copy link

sjoorm commented Aug 1, 2017

@fiboknacky I've solved this issue and proposed a pull request: #334

@fiboknacky
Copy link
Member

Hello @sjoorm

Thanks for your pull request.
You're right. It fails when denormalizing arrays of scalar values.
I'm actually working on the fix as well but haven't released it yet.
Let's discuss about this in your pull request.

As for finalUrl, the data returned from the API servers will be one value even for arrays, but the code handles this in this line to ensure that it'll be finally converted to an array of one value.

Best,
Knack

@fiboknacky
Copy link
Member

This is fixed since v28.1.0.
Please let me know if you still have this issue.

@Babis86
Copy link
Author

Babis86 commented Aug 16, 2017

@fiboknacky
It works now thanks for the fix.

Best,
babis86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants