Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidArgument - PAGE_SIZE_NOT_SUPPORTED even when not setting SearchGoogleAdsRequest.PageSize or default value for pageSize parameter #589

Open
b-levitt opened this issue Dec 4, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@b-levitt
Copy link

b-levitt commented Dec 4, 2024

V17/V18 throws 'PAGE_SIZE_NOT_SUPPORTED' even when the field/param is set to default

Steps to Reproduce:
Linqpad script using 21.1.1 Google.Ads nuget:

`void Main()
{
GoogleAdsServiceClient _googleAdServiceClient;

var _config = new GoogleAdsConfig(new Dictionary<string, string> {
		{ "AuthorizationMethod", "OAuth2" },
		{ "DeveloperToken", "xxxx" },
		{ "OAuth2ClientId", "xxxx.apps.googleusercontent.com" },
		{ "OAuth2ClientSecret", "xxxx" },
		{ "OAuth2RefreshToken", "xxxx" },
		{ "OAuth2Mode", "APPLICATION" },
		{ "LoginCustomerId", "xxxx" }
	});

var _client = new GoogleAdsClient(_config);
_googleAdServiceClient = _client.GetService(Services.V18.GoogleAdsService);



var search = new SearchGoogleAdsRequest();
search.Query =
	@$"SELECT
	campaign.id,
	campaign.name,
	campaign.status,
	metrics.average_cpc,
	metrics.average_cpm,
	metrics.average_cost,
	metrics.clicks,
	metrics.impressions,
	segments.date,
	ad_group.id,
	ad_group.name
	FROM ad_group WHERE campaign.status != 'REMOVED' AND segments.date >= '2024-11-01' AND segments.date <= '2024-12-3'";
search.CustomerId = "9999999";

Page<GoogleAdsRow> results = null;

var request = _googleAdServiceClient.Search(search);
//****************     exception thrown here  vvvvvvvvvvvvvvvvv
results = request.ReadPage(10000);

}

`

Expected behavior:
PageSize not set in output with at least ONE "magic" page size, allowing for use of the latest V17/V18 api

Client library version and API version:
Client library version:21.1.1
Google Ads API version:17 and 18
.NET version:
.net 8

Request/Response Logs:
Nothing is logged when setting ReadPage(0). When pageSize into ReadPage is given, you can see it in the request:

GoogleAds.DetailedRequestLogs Information: 1 : [2024-12-04 17:54:08Z] -
---------------BEGIN API CALL---------------

Request

Method Name: /google.ads.googleads.v17.services.GoogleAdsService/Search
Host:
Headers: {
"x-goog-api-client": "gl-dotnet/3.1.0 gapic/21.1.1 gax/4.8.0 grpc/2.60.0 gccl/4.0.3 pb/3.25.0",
"developer-token": "REDACTED",
"login-customer-id": "1234665825",
"x-goog-request-params": "customer_id=2305300261"
}

{ "customerId": "2305300261", "query": "SELECT\r\n\t\tcampaign.id,\r\n\t\tcampaign.name,\r\n\t\tcampaign.status,\r\n\t\tmetrics.average_cpc,\r\n\t\tmetrics.average_cpm,\r\n\t\tmetrics.average_cost,\r\n\t\tmetrics.clicks,\r\n\t\tmetrics.impressions,\r\n\t\tsegments.date,\r\n\t\tad_group.id,\r\n\t\tad_group.name\r\n\t\tFROM ad_group WHERE campaign.status != 'REMOVED' AND segments.date \u003e= '2024-11-01' AND segments.date \u003c= '2024-12-03'", "pageSize": 10 }

Response

Headers: {
"request-id": "HdZbTjBpWqp8W46HU5NYSQ",
"date": "Wed, 04 Dec 2024 17:54:08 GMT",
"alt-svc": "h3=":443"; ma=2592000,h3-29=":443"; ma=2592000",
"google.ads.googleads.v17.errors.googleadsfailure-bin": "CmkKAggoEmNTZXR0aW5nIHRoZSBwYWdlIHNpemUgaXMgbm90IHN1cHBvcnRlZC4gU2VhcmNoIFJlc3BvbnNlcyB3aWxsIGhhdmUgZml4ZWQgcGFnZSBzaXplIG9mICcxMDAwMCcgcm93cy4SFkhkWmJUakJwV3FwOFc0NkhVNU5ZU1E=",
"grpc-status-details-bin": "CAMSJVJlcXVlc3QgY29udGFpbnMgYW4gaW52YWxpZCBhcmd1bWVudC4azAEKRHR5cGUuZ29vZ2xlYXBpcy5jb20vZ29vZ2xlLmFkcy5nb29nbGVhZHMudjE3LmVycm9ycy5Hb29nbGVBZHNGYWlsdXJlEoMBCmkKAggoEmNTZXR0aW5nIHRoZSBwYWdlIHNpemUgaXMgbm90IHN1cHBvcnRlZC4gU2VhcmNoIFJlc3BvbnNlcyB3aWxsIGhhdmUgZml4ZWQgcGFnZSBzaXplIG9mICcxMDAwMCcgcm93cy4SFkhkWmJUakJwV3FwOFc0NkhVNU5ZU1E="
}

Fault: {
"StatusCode": 3,
"Details": "Request contains an invalid argument.",
"RequestId": "HdZbTjBpWqp8W46HU5NYSQ",
"Failure": {
"errors": [
{
"errorCode": {
"requestError": "PAGE_SIZE_NOT_SUPPORTED"
},
"message": "Setting the page size is not supported. Search Responses will have fixed page size of '10000' rows."
}
],
"requestId": "HdZbTjBpWqp8W46HU5NYSQ"
}
}
----------------END API CALL----------------

Anything else we should know about your project / environment

I don't care what the page size is and I'm aware that as of V17 it is a fixed 10k:

https://ads-developers.googleblog.com/2024/06/announcing-v17-of-google-ads-api.html

However, there doesn't seem to be a way to take advantage of that new fixed size with the current .net implimentation since there is only one ReadPage(int pageSize) method, suggesting that you must set a page size. (A page size of 0 yields no rows).

@b-levitt b-levitt added the bug Something isn't working label Dec 4, 2024
@Raibaz
Copy link
Contributor

Raibaz commented Dec 4, 2024

You don't need to use the ReadPage(int pageSize) method, you can iterate or enumerate on the PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> object returned by Search.

Take a look at how this is handled, for instance, in the GetResponsiveSearchAds example: https://github.com/googleads/google-ads-dotnet/blob/main/Google.Ads.GoogleAds/examples/BasicOperations/GetResponsiveSearchAds.cs#L119

Hope this helps.

@b-levitt
Copy link
Author

b-levitt commented Dec 4, 2024

That's a good tip, thank you. I actually started converting to the preferred "SearchStream" method so either way I have a couple of workarounds.

That said if ReadPage does not work, shouldn't it be removed or marked as obsolete to be inline with the API documentation?

@Raibaz
Copy link
Contributor

Raibaz commented Dec 4, 2024

It's a good point, but the PagedEnumerable class and its ReadPage method are actually part of the generic gRPC library, they are not strictly Ads API-specific: https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.GrpcPagedEnumerable-3#Google_Api_Gax_Grpc_GrpcPagedEnumerable_3_ReadPage_System_Int32_

This being said, maybe we can just override it in the Ads API to ensure it's at least marked as obsolete.

@b-levitt
Copy link
Author

b-levitt commented Dec 5, 2024

Yeah anything really to dig the pit-of-success. As long as ReadPage is a method it is a distraction from the 'right' ways to do things and there's a disconnect between the api and this library. I understood that setting the page size was no longer supported from the api messaging, but the updated docs make it clear that paging IS still supported, just with fixed 10k pages. Even adding support info to the exception the case of this particular error would be fine - I'd take a runtime error that is specific to the library vs a generic one that points back to the api.

To be fair, before this issue I knew nothing about the api or the library but we new v16 support ends in 2025. My intent was to jump in to the code and just update those version numbers as I've done before but then ran into this error, thus diving down this rabbit hole. I think the streaming option is cleaner anyway, but i could have been pushed in that direction much faster with an obsolete tag or library specific exception message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants