googleads / google-api-ads-ruby

Ad Manager SOAP API Client Libraries for Ruby
297 stars 229 forks source link

`download_report_as_stream` ignores HTTP status code #176

Closed manu-crealytics closed 3 years ago

manu-crealytics commented 3 years ago

Using the download_report_as_stream method from report_utils.rb (see https://github.com/googleads/google-api-ads-ruby/blob/6e41f68ee8ecc3cf914523e3377e652f989ea497/adwords_api/lib/adwords_api/report_utils.rb#L95) does not apply any check over the HTTP response status code.

For example, sometimes the Google AdWords API fails with 500 Internal Server Error and the following response body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>ReportDownloadError.ERROR_GETTING_RESPONSE_FROM_BACKEND</type><trigger>Unable to read report data</trigger><fieldPath></fieldPath></ApiError></reportDownloadError>

In that example, download_report_as_stream simply ignores the 500 status code and just returns the response body (via calls to the user-provided Ruby block) and no exception is triggered. From the perspective of the application invoking download_report_as_stream it looks like the report was downloaded successfully, as there is no indication otherwise.

Would it be possible to have download_report_as_stream at least check the response status code and trigger an exception on non-200 values?

mcloonan commented 3 years ago

Thanks for the report. We're currently focusing all new development on the Google Ads API, which recently added streaming reporting options. I recommend that you switch over to the new API as soon as possible, since eventually the AdWords API will be turned down. Although we haven't mentioned any specific dates yet, and will provide ample time for migration, by swapping over now you would avoid that headache in the future.

Here's the Ruby library for the Google Ads API: https://github.com/googleads/google-ads-ruby And full documentation for the Google Ads API: https://developers.google.com/google-ads/api/docs/start

The Ruby library for the AdWords API is in maintenance mode so we're only going to be addressing critical bugs.