Azure / azure-cosmosdb-java

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

IllegalStateException when doing readMedia #85

Closed chetanmeh closed 5 years ago

chetanmeh commented 5 years ago

Upon reading attachments following exception is seen

java.lang.AssertionError: Unexpected onError events (0 completions) (+1 error)

    at rx.observers.TestSubscriber.assertionError(TestSubscriber.java:667)
    at rx.observers.TestSubscriber.assertNoErrors(TestSubscriber.java:416)
    at com.microsoft.azure.cosmosdb.rx.ReadFeedAttachmentsTest.validateReadEmbededAttachment(ReadFeedAttachmentsTest.java:180)
    at com.microsoft.azure.cosmosdb.rx.ReadFeedAttachmentsTest.readAndUpdateEmbededAttachments(ReadFeedAttachmentsTest.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:54)
    at org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: invalid resource type
    at com.microsoft.azure.cosmosdb.internal.PathsHelper.generatePath(PathsHelper.java:315)
    at com.microsoft.azure.cosmosdb.internal.PathsHelper.generatePath(PathsHelper.java:62)
    at com.microsoft.azure.cosmosdb.rx.internal.RxGatewayStoreModel.getUri(RxGatewayStoreModel.java:240)
    at com.microsoft.azure.cosmosdb.rx.internal.RxGatewayStoreModel.performRequest(RxGatewayStoreModel.java:178)
    at com.microsoft.azure.cosmosdb.rx.internal.RxGatewayStoreModel.read(RxGatewayStoreModel.java:131)
    at com.microsoft.azure.cosmosdb.rx.internal.RxGatewayStoreModel.invokeAsyncInternal(RxGatewayStoreModel.java:446)
    at com.microsoft.azure.cosmosdb.rx.internal.RxGatewayStoreModel.lambda$invokeAsync$11(RxGatewayStoreModel.java:460)
    at com.microsoft.azure.cosmosdb.rx.internal.BackoffRetryUtility.lambda$executeRetry$2(BackoffRetryUtility.java:102)

This is being seen since update to 2.4.0 release (see apache/incubator-openwhisk#4283). Currently only test which uses the readMedia api in ReadFeedAttachmentsTest#readAndUpdateEmbededAttachments is commented out. If the test is enabled then same error is seen

Environment summary SDK Version: 2.4.0 Java JDK version: 1.8 OS Version (e.g. Windows, Linux, MacOSX) MacOSX

chetanmeh commented 5 years ago

Seems like for ResourceType.Media has no handling in PathsHelper.generatePath. In v2.3.0 path was directly constructed from the RxDocumentServiceRequest and now it uses PathHelper which results in error thrown

moderakh commented 5 years ago

@chetanmeh not fully supporting ResourceType.Media is a bug however we are planning to deprecate attachment APIs and remove them in upcoming releases. Are you using these APIs in prod?

chetanmeh commented 5 years ago

We support two modes

  1. Store metadata in CosmosDB and Binary in any object store
  2. Store metadata in CosmosDB and binary as attachment

Prod usage is based on 1. However we have testcases and implementation logic for 2 also.

we are planning to deprecate attachment APIs and remove them in upcoming releases

So CosmosDB would remove support for attachment altogether or only SDK would not support it?

moderakh commented 5 years ago

I suggest you go with option 1.

For now we are planning to deprecate/remove attachments support across SDKs.

christopheranderson commented 5 years ago

Cleaning up issues. Closing as won't fix for now. Recommend using blob storage or some other external store. We won't be continuing support in newer versions of the SDK and once the old SDKs retire, it will be retired in the backend as well. Message us at AskCosmoDB@microsoft.com if that's a bigger issue.