Azure / azure-cosmosdb-java

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

CosmosContainer.replace() requires settings to include a self link #135

Closed dconnelly closed 5 years ago

dconnelly commented 5 years ago

Describe the bug CosmosContainer.replace() does not work unless container settings includes a self link. We should be able to determine the self link automatically so it doesn't have to be explicitly provided.

To Reproduce Attempt to replace a container with settings not including a self link.

Expected behavior Should probably be able determine self link from container id + database id.

Actual behavior Exception when attempting to replace container:

java.lang.IllegalArgumentException: Entity with the specified id does not exist in the system.
    at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceRequest.<init>(RxDocumentServiceRequest.java:202)
    at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceRequest.<init>(RxDocumentServiceRequest.java:232)
    at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceRequest.<init>(RxDocumentServiceRequest.java:273)
    at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceRequest.create(RxDocumentServiceRequest.java:410)
    at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentClientImpl.replaceCollectionInternal(RxDocumentClientImpl.java:676)
    at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentClientImpl.lambda$replaceCollection$12(RxDocumentClientImpl.java:660)
    at com.microsoft.azure.cosmosdb.rx.internal.ObservableHelper.lambda$inlineIfPossibleAsObs$1(ObservableHelper.java:55)
    at com.microsoft.azure.cosmosdb.rx.internal.BackoffRetryUtility.lambda$executeRetry$2(BackoffRetryUtility.java:102)

Environment summary SDK Version: v3 beta 3 Java JDK version: Java 8 OS Version (e.g. Windows, Linux, MacOSX) osx

Additional context Add any other context about the problem here.

dconnelly commented 5 years ago

Hmm, on second thought maybe it's always necessary to read an object first before replacing it, so will close this out for now.