Which API errors should be retried?

412 views
Skip to first unread message

Kristopher Windsor

unread,
Nov 18, 2014, 4:35:34 PM11/18/14
to adwor...@googlegroups.com
Hi,

When the Adwords API throws an Exception, I'd like to know if I should retry (intermittent errors) or not (bad input on my end).
I am using the PHP client library.

For example, I should retry for this case:
InternalApiError.UNEXPECTED_INTERNAL_API_ERROR

But not for this case:
BiddingError.BID_TOO_MANY_FRACTIONAL_DIGITS

Is there some way to determine if I should retry, other than just building a big list of retry-able / non-retry-able Exceptions?

Thanks,

Michael Cloonan (AdWords API Team)

unread,
Nov 19, 2014, 9:47:17 AM11/19/14
to adwor...@googlegroups.com
Hello,

There is no programmatic way to tell whether an error should be retried or not. For each use case where you're accessing the API, you should determine yourself how to handle various error cases.

You can use our common errors page as a starting point, which goes into details on certain kinds of errors, but it is not exhaustive.

Regards,
Mike, AdWords API Team

Oliver

unread,
Nov 20, 2014, 3:12:01 AM11/20/14
to adwor...@googlegroups.com
We retry when we see these errors:

ReportDownloadError.ERROR_GETTING_RESPONSE_FROM_BACKEND
ReportDownloadError.INTERNAL_SERVER_ERROR
ReportDownloadError.ERROR_WRITING_REPORT_TO_FILE
InternalApiError.UNEXPECTED_INTERNAL_API_ERROR
AuthorizationError.CUSTOMER_SYNC_DISABLED
DatabaseError.CONCURRENT_MODIFICATION
RateExceededError.RATE_EXCEEDED
AuthenticationError.OAUTH_TOKEN_INVALID

Also, any error that contains the following strings:

"temporary error"
"try again"
"404"


Oliver

Kristopher Windsor

unread,
Nov 20, 2014, 4:42:10 AM11/20/14
to adwor...@googlegroups.com
Thanks Michael and Oliver.

I want the default to be "do retry," and I wrote this today (PHP):

  public static function isRetriable($e){
   
if ($e instanceof SoapFault && @$e->detail->ApiExceptionFault->errors[0]->enc_value instanceof ApiError){
      $err
= $e->detail->ApiExceptionFault->errors[0]->enc_value;
     
if ($err instanceof ApiError){
       
// ie CRITERIA_TYPE_INVALID_FOR_BIDDING_STRATEGY_CONFIGURATION
       
if ($err->ApiErrorType == 'AdGroupCriterionError')
         
return false;
       
// ie INVALID_FORMAT_FOR_PLACEMENT_URL
       
if ($err->ApiErrorType == 'CriterionError')
         
return false;
     
}
   
}
   
return true;
 
}

I don't plan to handle all of the possible errors, just the ones I know we waste time retrying.

My main question is... should I be inspecting SoapFault this closely?
It seems like it is tedious to find the actual instances of ApiError within SoapFault.

Michael Cloonan (AdWords API Team)

unread,
Nov 20, 2014, 9:12:13 AM11/20/14
to adwor...@googlegroups.com
Hello,

If you are going to include automatic retry code, please do make sure that you use an exponential backoff in case you are accidentally retrying something that is never going to succeed. Even for a call that might eventually succeed, constantly hitting the server when there are server issues causing it to fail is counterproductive.

Thanks!
-Mike, AdWords API Team
Reply all
Reply to author
Forward
0 new messages