google-cloud-java icon indicating copy to clipboard operation
google-cloud-java copied to clipboard

Error in Google Analytics Admin

Open o7planning opened this issue 1 year ago • 1 comments

Hello, I discovered a small bug in version 0.41.0 of Google Analytics Admin:

AccountName name = AccountName.of("accounts/295326872"); 
Account response1 = analyticsAdmin.getAccount(name);

I got Error:

Exception in thread "main" com.google.api.pathtemplate.ValidationException: Invalid character "/" in path section "accounts/295326872".
	at com.google.api.pathtemplate.PathTemplate.encodeUrl(PathTemplate.java:1099)
	at com.google.api.pathtemplate.PathTemplate.instantiate(PathTemplate.java:768)
	at com.google.api.pathtemplate.PathTemplate.instantiate(PathTemplate.java:691)
	at com.google.api.pathtemplate.PathTemplate.instantiate(PathTemplate.java:700)
	at com.google.analytics.admin.v1beta.AccountName.toString(AccountName.java:122)
	at com.google.analytics.admin.v1beta.AnalyticsAdminServiceClient.getAccount(AnalyticsAdminServiceClient.java:208)
	at test.QuickstartSample.listAccounts(QuickstartSample.java:32)
	at test.QuickstartSample.main(QuickstartSample.java:17)

But I changed above code with:

Account response1 = analyticsAdmin.getAccount("accounts/295326872")

I worked!

o7planning avatar Dec 05 '23 19:12 o7planning

Hi @o7planning, sorry I didn't see this earlier. Thanks for reporting this, but I think the behavior for AccountName is correct.

I see the original definition for this resource here: https://github.com/googleapis/googleapis/blob/9a9bc9b427e4516f79b9753c4fad91d425334755/google/analytics/admin/v1alpha/resources.proto#L344-L348

which looks like you would only need to supply the account value.

The generated resource is here: https://github.com/googleapis/google-cloud-java/blob/728f84161537795d9d4fd551bf680afe16e87e3a/java-analytics-admin/proto-google-analytics-admin-v1alpha/src/main/java/com/google/analytics/admin/v1alpha/AccountName.java. Can you try running AccountName.of("295326872")?

lqiu96 avatar Feb 15 '24 15:02 lqiu96

Closing due to lack of response. @o7planning please feel free to re-open this ticket if you're still running into this issue even after running AccountName.of("295326872")!

mpeddada1 avatar May 08 '24 22:05 mpeddada1