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
290 stars 260 forks source link

Internal error encountered. - not catchable #932

Open chiragvels opened 1 year ago

chiragvels commented 1 year ago

[DO NOT INCLUDE ANY PERSONAL OR SENSITIVE DATA - MAKE SURE TO REDACT CONTENT WHEN NECESSARY]

Your question: The encountered internal error is not catchable. I attempted to catch the error using various methods, but but it was not catchable. Instead, it simply breaks the cron process.

try {
     $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
} catch (GoogleAdsException $googleAdsException) {
            throw $googleAdsException;
        } catch (ApiException $apiException) {
            throw $apiException;
        } catch (Exception $e) {
            throw $e;
        }

Private Reply by forum:

Can you confirm if you are using the PHP client library? If yes, with regards to your concern, since your concern is more on the code implementation on how to catch this kind of exception error in the Google Ads API PHP client library, you may try reaching out to the developer who maintains our client libraries PHP (Github Issues) via this link (https://github.com/googleads/google-ads-php/issues) for further insights on how to catch this kind of error.

Reference: https://groups.google.com/g/adwords-api/c/tkvPnT-fmMo/m/IYS31igSAgAJ

How I can catch error which falls under Internal error encountered.

Thanks,

chiragvels commented 1 year ago

Hello,

May I receive some assistance here, please?

Thanks

fiboknacky commented 1 year ago

Hello Chirag,

Sorry for keeping you waiting. I didn't realize you've created this issue. Will take a look soon. By the way, you used Google Ads API v13 with grpc, correct? Would you mind sharing other information like the grpc, protobuf and gax-php version? And do you still face this issue when running the same query? (I can check your query internally, so you don't need to share it here)

Knack

chiragvels commented 1 year ago

Hello Knack,

Sorry for keeping you waiting. I didn't realize you've created this issue. Will take a look soon.

By the way, you used Google Ads API v13 with grpc, correct?

Yes correct.

Would you mind sharing other information like the grpc, protobuf and gax-php version?

================= PHP EXTENSION INFORMATION The PHP Extension grpc is installed: 1.54.0 The PHP Extension protobuf is installed: 3.22.3 PHP Version => 8.1.2-1ubuntu2.13 "x-goog-api-client": "gl-php\/8.1.2-1ubuntu2.13 gccl\/20.0.0 gapic\/20.0.0 gax\/1.19.1 grpc\/1.54.0 rest\/1.19.1 pb\/3.22.3+c",

And do you still face this issue when running the same query? (I can check your query internally, so you don't need to share it here)

fiboknacky commented 1 year ago

Could you please also share the version of google/gax too? Thanks.

chiragvels commented 1 year ago

I have also included the gax version information in my previous response.

gax/1.19.1

"name": "google/gax",
            "version": "v1.19.1",
            "source": {
                "type": "git",
                "url": "https://github.com/googleapis/gax-php.git",
                "reference": "30f6b307faa9858bf58d967664467098dbbc354f"
            },
fiboknacky commented 1 year ago

Hi Chirag,

I'm trying to reproduce the error you got, but so far I cannot do it yet.

Having said that, from the error you shared on the forum, it looks like the library should be able to recognize the error because the type is google.ads.googleads.v13.errors.googleadsfailure-bin.

Digging deeper, I think that the internal error you got probably is not an ApiException instance, and probably falls out of this if clause. And what you saw is probably just an error message thrown up from the bottom of the stack by the throw statement.

Could you help me verify this? Maybe you can add something around that if clause to check if my assumption is true. If yes, we can think about adding support for this internal error going forward. Thanks!

chiragvels commented 1 year ago

Hi Knack,

Could you help me verify this? Maybe you can add something around that if clause to check if my assumption is true.

Yes, it is. Yesterday, I encountered an internal error. However, when I attempted to debug the issue, I was unable to reproduce the error while rerunning the same example. As a result, I'm not entirely certain about the nature of the problem.

Thanks,

fiboknacky commented 1 year ago

OK. Please let me know when you can reproduce it. For now, I suspect that somehow the internal error thrown by the server wasn't created as an instance of ApiException. And that's why the exception is thrown as is, but I still wonder why it's not at least an instance of Exception, so you can catch it.

If it's not even an Exception, we probably need to dig deeper.

chiragvels commented 11 months ago

I have faced same issue again.

An uncaught Exception was encountered

Type:        Google\Ads\GoogleAds\Lib\V13\GoogleAdsException
Message:     {
    "message": "Internal error encountered.",
    "code": 13,
    "status": "INTERNAL",
    "details": [
        {
            "@type": "google.ads.googleads.v13.errors.googleadsfailure-bin",
            "data": "<Unknown Binary Data>"
        },
        {
            "@type": "grpc-status-details-bin",
            "data": "<Unknown Binary Data>"
        },
        {
            "@type": "request-id",
            "data": "SwfPxA_CISpD_3bpjNnoDA"
        }
    ]
}

I think you are right its not creating instance of ApiException.

Filename: /vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V13/GoogleAdsExceptionTrait.php
Line Number: 75

Backtrace:
    File: /vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V13/GoogleAdsExceptionTrait.php
    Line: 50
    Function: createGoogleAdsException

    File: /vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V13/ServerStreamingGoogleAdsExceptionMiddleware.php
    Line: 96
    Function: throwGoogleAdsException

    File: /vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V13/ServerStreamingGoogleAdsResponseMetadataCallable.php
    Line: 63
    Function: readAll

Thanks,

fiboknacky commented 11 months ago

Is it not even Exception either? That would be a surprise to me.

chiragvels commented 11 months ago

Yes, This is not even honoured Exception.

fiboknacky commented 11 months ago

That's weird. We may need to file a bug on the gax-php repo.

chiragvels commented 11 months ago

Ok. What details must we include when filing a bug on gax-php repo.?

fiboknacky commented 11 months ago

Taking a look at your recent report again, it looks like it was thrown as Exception? So, wasn't it caught at the last catch?

chiragvels commented 11 months ago

Yes, It wasn't caught at the last catch?

fiboknacky commented 11 months ago

That's quite weird, since it says that the uncaught exception is Google\Ads\GoogleAds\Lib\V13\GoogleAdsException. It should have been caught at the first catch. 🤔

chiragvels commented 11 months ago

Yes, But I was getting out of loop when Internal Error encountered and cron jobs are killed.