Azure / azure-cosmosdb-java

Java Async SDK for SQL API of Azure Cosmos DB
MIT License
54 stars 61 forks source link

Cannot set MaxItemCount to -1 through Java SDK #261

Closed avakutin closed 4 years ago

avakutin commented 4 years ago

Describe the bug The documentation states that the maxItemCount property in the FeedOptions can be set to -1 to allow for the SDK to choose the optimal value, however, setting the maxItemCount to -1 returns a 400 with the message "One of the input values is invalid.: argumentName: MaxItemCount, message: Invalid MaxItemCount -1"

The stack trace points to a validation line in DocumentQueryExecutionContextFactory.createSpecializedDocumentQueryExecutionContextAsync:

BadRequestException validationError = Utils.checkRequestOrReturnException (initialPageSize > 0, "MaxItemCount", "Invalid MaxItemCount %s", initialPageSize);

To Reproduce FeedOptions options = new FeedOptions(); options.setMaxItemCount(-1);

Send cosmos request with the FeedOptions

Expected behavior Should be able to set maxItemCount to -1 through the SDK

Actual behavior BadRequestException{error=null, resourceAddress='null', statusCode=400, message=One of the input values is invalid.: argumentName: MaxItemCount, message: Invalid MaxItemCount -1, getCauseInfo=null, responseHeaders={}, requestHeaders=null}

Environment summary Java JDK version: 2.6.1

kushagraThapar commented 4 years ago

@mbhaskar this is a bug in the SDK. https://github.com/Azure/azure-cosmosdb-java/blob/master/gateway/src/main/java/com/microsoft/azure/cosmosdb/rx/internal/query/DocumentQueryExecutionContextFactory.java#L183

We should also fix this in v3, and possibly v4.

kushagraThapar commented 4 years ago

This has been released as v2.6.2, closing this issue.