Closed
Description
openedon Jul 30, 2021
Describe the bug
Using the container.ReadManyItemsAsync(..)
function to retrieve multiple documents where the partition key is set to PartitionKey.None throws an ArgumentException with the message
PartitionKey has fewer components than defined the collection resource.
To Reproduce
Call ReadManyItemsAsync in a similar fashion to:
var ids = new List<string> { "0" };
var results = await container.ReadManyItemsAsync(ids.ConvertAll(id => (id, PartitionKey.None)));
Expected behavior
No ArgumentException thrown.
Actual behavior
ArgumentException thrown with the following exception.ToString():
System.ArgumentException: PartitionKey has fewer components than defined the collection resource.
at Microsoft.Azure.Documents.Routing.PartitionKeyInternal.GetEffectivePartitionKeyString(PartitionKeyDefinition partitionKeyDefinition, Boolean strict)
at Microsoft.Azure.Cosmos.ReadManyQueryHelper.CreatePartitionKeyRangeItemListMapAsync(IReadOnlyList`1 items, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.ReadManyQueryHelper.ExecuteReadManyRequestAsync[T](IReadOnlyList`1 items, ReadManyRequestOptions readManyRequestOptions, ITrace trace, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.ContainerCore.ReadManyItemsAsync[T](IReadOnlyList`1 items, ITrace trace, ReadManyRequestOptions readManyRequestOptions, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.ClientContextCore.RunWithDiagnosticsHelperAsync[TResult](ITrace trace, Func`2 task)
at Microsoft.Azure.Cosmos.ClientContextCore.OperationHelperWithRootTraceAsync[TResult](String operationName, RequestOptions requestOptions, Func`2 task, TraceComponent traceComponent, TraceLevel traceLevel)
at ...
Environment summary
SDK Version: 3.20.1
OS Version: Windows 10
Additional context
A call to container.ReadItemAsync("0", PartitionKey.None)
works as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment