question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Property Body on CloudException is null

See original GitHub issue

Describe the bug The property Body is null on CloudException when the exception is created from a bad request to https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/usages?{api_version}

I found that the error is happening because the response is an scaped string and not a Json, so the Deserialize throw a JsonException and the Body is never set for that reason.

Exception or Stack Trace

To Reproduce Send a proper request to the endpoint mentioned above with a not supported location in order to get a Bad Request response. Try to parse the Response Content to a CloudError Object Catch the JsonException.

Code Snippet From https://github.com/Azure/azure-sdk-for-net/commit/149dd1b6b4889f5c3b730aa86eaa3e41ec451604 Operation.cs

var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception }

Expected behavior Get a well formated Json Parse the Json Map to CloudError properly

Screenshots image

Setup (please complete the following information):

  • OS: Windows 10
  • IDE : Visual Studio Professional 2017
  • Version of the Library used

Additional context

Information Checklist

  • [ X ] Bug Description Added
  • [ X ] Repro Steps Added
  • [ X ] Setup information Added

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kurtzeborncommented, Jun 10, 2019

Thank you for opening this issue! We are routing it to the appropriate team for follow up.

0reactions
erich-wangcommented, Jul 26, 2019

@leagallino , the issue could not be reproduced and don’t get response for 10 days, so close it. Please feel free to reopen it if you could reproduce it, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while creating Work Item in Azure Devops using Rest ...
Looking through the error message, appears like you are passing the Content Type : "application/json". You will have to pass the Content ...
Read more >
Azure PowerShell release notes
Changed 'gallery' property to be optional in ARM metadata of ... Addressed bug in 'Remove-AzVmss' to throw error when '-InstanceId' is null.
Read more >
How to handle 'A null value was found for the property' ...
When I was using those null values and tried to create a record in the target system (FO) I was running into the...
Read more >
Microsoft.Rest.ClientRuntime.Azure.xml 0.4.6
Gets information about the associated HTTP response. </summary> </member> <member name="P:Microsoft.Rest.Azure.CloudException.Body">
Read more >
Failed to Configure the Organization Error When Trying ...
This issue occurs when you have an invalid API key in your configuration that isn't recognized by Coveo. Resolution. You need to regenerate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found