-
Notifications
You must be signed in to change notification settings - Fork 103
Description
When using the google-ads-api library (version 19.0.4-rest-beta) in a Cloudflare Workers environment, calls to customer.report() result in an Axios error: Google Ads Client Error: Response type 'stream' is not supported. This occurs despite customer.report() being part of the REST interface, which is expected to be more compatible with environments that do not support Node.js-style streams (like Cloudflare Workers).
To Reproduce Steps to reproduce the behavior:
- Set up a Cloudflare Worker project.
- Install google-ads-api@19.0.4-rest-beta.
- Initialize GoogleAdsApi and a Customer instance with valid OAuth credentials (client ID, client secret, refresh token, developer token) and a customer ID.
- Attempt to execute a report request using customer.report(reportOptions). Example reportOptions:
const reportRequest = {
entity: "campaign" as fields.Resource, // Using type assertion as per strict types
attributes: [
"campaign.id" as fields.Attribute,
"campaign.name" as fields.Attribute,
],
order: [
{
field: "campaign.name" as fields.Attribute,
sort_order: "ASC" as const,
},
],
limit: 5,
};
const results = await customer.report(reportRequest);
- The call fails with the aforementioned error.
Expected behavior The customer.report() method in the REST-beta version of the library should successfully execute queries against the Google Ads API REST interface without attempting to use response types (like 'stream') that are incompatible with browser-like or Cloudflare Workers environments. The response should be a standard JSON payload.
Actual behavior The customer.report() call throws an AxiosError wrapped by the library:
{
"error": {
"code": 500,
"message": "Google Ads Client Error: Response type 'stream' is not supported",
"status": "CLIENT_LIBRARY_ERROR",
"details": [
{
"errorCode": { "clientError": "AxiosError" },
"message": "Response type 'stream' is not supported"
}
]
}
}
Environment:
google-ads-api version: 19.0.4-rest-beta
Node.js version: [Specify your local Node.js version, though the issue is in CF Workers runtime]
OS: [Specify your local OS, though the issue is in CF Workers runtime]
Runtime Environment: Cloudflare Workers
Additional context/attempts:
The issue was initially encountered with customer.query() and the switch to customer.report() was made specifically to leverage the REST interface, hoping to avoid stream-related problems.
Type assertions (as fields.Resource, as fields.Attribute) were necessary to satisfy TypeScript for ReportOptions due to strict type definitions in 19.0.4-rest-beta.
We investigated using the onQueryStart hook with editOptions to potentially modify the underlying Axios request options (e.g., to set responseType: 'json'). However, editOptions only accepts Partial which is based on the Google Ads API schema (services.ISearchGoogleAdsRequest) and does not seem to provide a passthrough for underlying HTTP client configurations like Axios's responseType.
This issue prevents the use of the google-ads-api (REST beta) for reporting in Cloudflare Workers. Any guidance on how to configure the underlying HTTP client or a fix from the library would be greatly appreciated.