azure-sdk-for-go: insights.ActivityLogsClient.ListComplete handling pagination incorrectly and gets 500 ISE on the 3rd page

The following happens with azure-sdk-for-go v55.0.0, import path is github.com/Azure/azure-sdk-for-go/profiles/2020-09-01/monitor/mgmt/insight.

We noticed that there’s an issue with the pagination in ListtComplete. Consider the following iteration loop on the results:

for eventsSubList, err := client.ListComplete(ctx, filter, ""); err != nil || eventsSubList.NotDone(); err = eventsSubList.NextWithContext(ctx) {
	...
}

Where filter is “eventTimestamp ge %s and eventTimestamp le %s and resourceId eq ‘%s’” and resourceId is a storage account in our case.

When iterating to the 3rd page, the client receives 500 ISE from the server.

The first response from the server includes the following NextLink:

"https://management.azure.com/subscriptions/subscriptionId/providers/microsoft.insights/eventtypes/management/values?%24filter=eventTimestamp+ge+2021-04-22T08%3A52%3A32.894533268Z+and+eventTimestamp+le+2021-07-21T07%3A52%3A32.894533268Z+and+resourceId+eq+%27%2Fsubscriptions%2FsubscriptionId%2Fresourcegroups%2FresourceGroupName%2Fproviders%2Fmicrosoft.storage%2Fstorageaccounts%2FstorageAccountName%27&api-version=2015-04-01&$skipToken=EU1:-1:FFFFFFFF;US1:0637592029774418052:d5291b61;AS1:-1:FFFFFFFF"

The following API call returns this as the next link:

https://management.azure.com/subscriptions/subscriptionId/providers/microsoft.insights/eventtypes/management/values?%24filter=eventTimestamp+ge+2021-04-22T08%3A52%3A32.894533268Z+and+eventTimestamp+le+2021-07-21T07%3A52%3A32.894533268Z+and+resourceId+eq+%27%2Fsubscriptions%2FsubscriptionId%2Fresourcegroups%2FresourceGroupName%2Fproviders%2Fmicrosoft.storage%2Fstorageaccounts%2FstorageAccountName%27&%24skipToken=EU1%3A-1%3AFFFFFFFF&AS1%3A-1%3AFFFFFFFF=&US1%3A0637592029774418052%3Ad5291b61=&api-version=2015-04-01&$skipToken=EU1:-1:FFFFFFFF;US1:0637592029774418052:d5291b61;AS1:-1:FFFFFFFF

The client gets 500 ISE when attempting to fetch the next page.

Using a debugger, I see that the actual request being sent is

https://management.azure.com/subscriptions/subscriptionId/providers/microsoft.insights/eventtypes/management/values?%24filter=eventTimestamp+ge+2021-04-22T08%3A52%3A32.894533268Z+and+eventTimestamp+le+2021-07-21T07%3A52%3A32.894533268Z+and+resourceId+eq+%27%2Fsubscriptions%2FsubscriptionId%2Fresourcegroups%2FresourceGroupName%2Fproviders%2Fmicrosoft.storage%2Fstorageaccounts%2FstorageAccountName%27&%24skipToken=EU1%3A-1%3AFFFFFFFF&%24skipToken=EU1%3A-1%3AFFFFFFFF&AS1%3A-1%3AFFFFFFFF=&AS1%3A-1%3AFFFFFFFF=&US1%3A0637592029774418052%3Ad5291b61=&US1%3A0637592029774418052%3Ad5291b61=&api-version=2015-04-01

Doing the same with az rest fails the same.

It looks like both client and server don’t handle the $skipToken well, as the client sends two versions of it, one encoded and one that is not; the server doesn’t handle that either.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 32 (14 by maintainers)

Most upvoted comments

I ran it with dlv and took out the url from there.

I’ll run it tomorrow with the debug env var tomorrow and paste here the output.