microsoft / Partner-Center-Java

Partner Center SDK for Java
https://docs.microsoft.com/java/partnercenter/
31 stars 12 forks source link

Lost data. Not idempotent response #114

Open msize opened 4 years ago

msize commented 4 years ago

Steps to reproduce

At the 2020-01-27T04:01:12Z we sent a request:

GET https://api.partnercenter.microsoft.com/v1/customers/{CUSTOMER}/subscriptions/{SUBSCRIPTION}/utilizations/azure?start_time=2020-01-26T02:00:00Z&end_time=2020-01-26T22:00:00Z&granularity=Hourly&show_details=true&size=500

And then received a response with code 200 OK and content-Length 318120. This response contained the next link. And we sent next request:

GET https://api.partnercenter.microsoft.com/v1/customers/{CUSTOMER}/subscriptions/{SUBSCRIPTION}/utilizations/azure?seek_operation=Next

And then received a response with code 204 No Content and content-Length 0.

It is bad. Because the response is not complete. And if we'll repeat this operation today it's returns data. And then more 9 pages.

In the application, we use IResourceCollectionEnumerator and methods hasValue and next. Like this:

final ResourceCollection<AzureUtilizationRecord> utilization = getUtilization(partner, usage);
if (utilization == null) {
    return;
}
final IResourceCollectionEnumerator<ResourceCollection<AzureUtilizationRecord>> pages =
        partner.getEnumerators().getUtilization().getAzure().create(utilization);

while (pages.hasValue()) {
    usage.append(pages.getCurrent().getItems(), price);
    pages.next();
}

And as you can see, we can't detect when the response is not complete and when it full. And this behavior became an issue with lost some data for us.

Expected behavior

Throw exception if the Next operation hasn't data.

Actual behavior

Returns empty data.

msize commented 4 years ago

@isaiahwilliams Could you comment on this issue?