You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unable to access the StatusCode property when the Status of operation is “Unauthorized”. It seems to be not accessible via CosmosException unlike other exception types.
#784
We are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.
Describe the bug
Unable to access the StatusCode property when the Status of operation is “Unauthorized”.
It seems to be not accessible via CosmosException unlike other exception types.
To Reproduce
try
{
var cosmosClient = new CosmosClient(
connectionProperties.EndpointUri,
connectionProperties.PrimaryAuthorizationKey,
new CosmosClientOptions()
{
ConnectionMode = ConnectionMode.Direct,
});
var accountProperties = cosmosClient.ReadAccountProperties( ...parameter values...) ... missed adding an operation earlier.
}
catch (CosmosException cosmosException)
{
if (cosmosException.StatusCode.Equals(HttpStatusCode.Unauthorized))
{
// This condition is never met. Instead base “Exception” is thrown
}
}
catch (Exception ex)
{
// Fails on following condition when "statusCode" is "Unauthorized"
var code = ((Microsoft.Azure.Documents.DocumentClientException)ex).StatusCode;
}
Expected behavior
CosmosException type should inlcude the Status code even for "Unauthorized" operation
Actual behavior
Base Exception is thrown without access to the "Status Code" Environment summary
SDK Version: 3.1.1
OS Version : Windows
Additional context
Add any other context about the problem here (for example, complete stack traces or logs).
The text was updated successfully, but these errors were encountered:
Which character? Because I'm using your code with the Emulator credentials, and changing one of the middle letters, and it doesn't throw, because it's a valid base64 still.
Now, if I change the last ones for example, I get a FormatException, because the string is no longer a valid base64.
try
{
var cosmosClient = new CosmosClient(
"https://localhost:8081",
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIr/Jw==",
new CosmosClientOptions()
{
ConnectionMode = ConnectionMode.Direct,
});
var document = await cosmosClient.GetContainer("test", "test").ReadItemAsync<dynamic>("test", new PartitionKey("test"));
}
catch (Exception ex)
{
// This is a DCE
}
Describe the bug
Unable to access the StatusCode property when the Status of operation is “Unauthorized”.
It seems to be not accessible via CosmosException unlike other exception types.
To Reproduce
try
{
var cosmosClient = new CosmosClient(
connectionProperties.EndpointUri,
connectionProperties.PrimaryAuthorizationKey,
new CosmosClientOptions()
{
ConnectionMode = ConnectionMode.Direct,
});
var accountProperties = cosmosClient.ReadAccountProperties( ...parameter values...) ... missed adding an operation earlier.
}
catch (CosmosException cosmosException)
{
if (cosmosException.StatusCode.Equals(HttpStatusCode.Unauthorized))
{
// This condition is never met. Instead base “Exception” is thrown
}
}
catch (Exception ex)
{
// Fails on following condition when "statusCode" is "Unauthorized"
var code = ((Microsoft.Azure.Documents.DocumentClientException)ex).StatusCode;
}
Expected behavior
CosmosException type should inlcude the Status code even for "Unauthorized" operation
Actual behavior
Base Exception is thrown without access to the "Status Code"
Environment summary
SDK Version: 3.1.1
OS Version : Windows
Additional context
Add any other context about the problem here (for example, complete stack traces or logs).
The text was updated successfully, but these errors were encountered: