-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CosmosClient with wrong key throws DocumentClientException instead of CosmosException #1906
Comments
|
1 - I am not catching it. If I debug I can see the type of the exception. I did try to import the nuget package "Microsoft.Azure.DocumentDB.Core" which imports the type (DocumentClientException), however the exception still does not fall on that catch block, although while debugging it shoes the type as being DocumentClientException |
Could it be that you are getting some logs / events? Sometimes the SDK does have DocumentClientException internally that might popup in event tracing, but the public facing type is CosmosException (there are places where we convert the DocumentClientException to CosmosException before doing the actual throw). |
Can you provide the full exception with the stack trace? |
@j82w This reproes on Write operations:
|
@NRam0s was right about the location for the fix, sharing PR in a min |
Thanks guys 👍 |
Closing due to in-activity, pease feel free to re-open. |
This ticket relates with another one that was been previously closed (#785). I have basically implemented exactly what was described on that ticket.
I am trying to create a cosmos client with a wrong key. I am able to get a DB and a container but as soon as I try to do a container action I get a DocumentClientException.
We are using Microsoft.Azure.Cosmos 3.13.0
One of my colleagues did some research and he found that the issue might be on this line of code. It might need to be inside the try catch: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs#L332
Some more details I have found. If we initialize the client with a valid key and then the key gets rotated, we get the CosmosException as expected with the following details:
Response status code does not indicate success: Unauthorized (401); Substatus: 0; ActivityId: XXX; Reason: (Message: {"Errors":["The MAC signature found in the HTTP request is not the same as the computed signature. Server used following string to sign - XXX...
However, as I mentioned above, the DocumentClientException is still thrown if the client is initialized already with an invalid key.
The text was updated successfully, but these errors were encountered: