googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
280 stars 260 forks source link

ListBatchJobResults Internal error encountered with responseContentType MUTABLE_RESOURCE #995

Closed LoreSco closed 6 months ago

LoreSco commented 6 months ago

Your client library and Google Ads API versions:

Laravel v10.39.0 running on AWS Lambda using bref php layer PHP 8.2.12 transport gRPC using bref grpc-php-82 layer

Description of the bug: I think I'm facing same issue as this one https://github.com/googleads/google-ads-php/issues/525 .

When retrieving a batchJob via

$batchJobServiceClient->listBatchJobResults($batchId, [
'pageSize' => 1000,
'responseContentType' => ResponseContentType::MUTABLE_RESOURCE
);

with a batch containing Create MutateOperation i get an Internal error encountered, code 13, when doing it with a batch of Update MutateOperation everything works fine. I tried lowering the page size from 1000 to 500 to 100 but to no avail.

Steps to reproduce: Create a BatchJob with Create MutateOperation. In my case the Mutate are 2 Campaigns, 1 CampaignBudget, 1 CampaignLabel and some CampaignCriterion. In this specific request 2 CampaignCriterion failed but I'm facing the same issue also with BatchJob that have succeed on all operations.

$batchJobServiceClient = $this->client->getBatchJobServiceClient();
        $batchJobResourceName = $batchJobServiceClient->mutateBatchJob(
            $this->accountId,
            (new BatchJobOperation())->setCreate(new BatchJob())
        )->getResult()->getResourceName();

        $chunkedOperations = array_chunk($operations, self::BATCH_OPERATIONS_PAGE_SIZE, true);
        $optionalArgs = [];
        foreach ($chunkedOperations as $operationsChunk) {
            $res = $batchJobServiceClient->addBatchJobOperations(
                $batchJobResourceName,
                $operationsChunk,
                $optionalArgs
            );
            $optionalArgs['sequenceToken'] = $res->getNextSequenceToken();
        }
        $batchJobServiceClient->runBatchJob($batchJobResourceName);

        return $batchJobResourceName;

List batch jobs results:

        $optionalArgs = [
            'pageSize' => self::BATCH_OPERATIONS_PAGE_SIZE,
            'responseContentType' => ResponseContentType::MUTABLE_RESOURCE
        ];
        $batchJobResults = $this->client->getBatchJobServiceClient()
            ->listBatchJobResults($batchId, $optionalArgs);

Expected behavior: Retrieving BatchJobResults successfully.

Request/Response Logs:

Method Name: /google.ads.googleads.v15.services.BatchJobService/ListBatchJobResults Host: googleads.googleapis.com Headers: { "x-goog-api-client": "gl-php\/8.2.14 gccl\/21.1.0 gapic\/21.1.0 gax\/1.26.2 grpc\/1.57.0 rest\/1.26.2 pb\/+n", "User-Agent": "gcloud-php-legacy\/21.1.0", "x-goog-request-params": "resource_name=customers%2FREDACTED%2FbatchJobs%2F19802626206", "developer-token": "REDACTED", "login-customer-id": "****" } Request: {"resourceName":"customers\/REDACTED\/batchJobs\/19802626206","pageSize":1000,"responseContentType":"MUTABLE_RESOURCE"}

Response

Headers: { "request-id": "Aj0qtnOWang2X72N5YaTbQ", "date": "Wed, 07 Feb 2024 09:32:08 GMT", "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" }

Fault

Status code: 13 Details: Internal error encountered. Failure: {"requestId":"Aj0qtnOWang2X72N5YaTbQ"}

Anything else we should know about your project / environment:

fiboknacky commented 6 months ago

This is the error on the server side. Could you please post on the Google Ads API forum? Thanks.