Skip to content

Conversation

@houk-ms
Copy link
Contributor

@houk-ms houk-ms commented Dec 15, 2020

Description

This PR tries to fix the issue Azure/azure-cli-extensions#2793.

For HttpOperationError, we can find its error message either in HttpOperationError.response.text and HttpOperationError.message. E.g, for the case above, the error message in HttpOperationError.message is

Operation returned an invalid status code 'Bad Request'

and the error message in HttpOperationError.response.text is like below, which is more explicit

{"Error":{"Code":"ValidationFailed","Message":"Updating immutable properties is not allowed."}}

Previously in AzureCLI core, the exception handler firstly tries to parse the HttpOperationError.response.text (usually a dict), and when that fails, it falls back to use HttpOperationError.message.

While the problem is the HttpOperationError.response.text is not a standard structure to parse, so we have to try to parse it according to the possible response structures. It means that we may also get a response like this

{"error":{"code":"ValidationFailed","message":"Updating immutable properties is not allowed."}}

Testing Guide

For the issue above, follow the reproducing steps there

Previously, you'll get the error message

BadRequestError: Operation returned an invalid status code 'Bad Request'

Now, you will get the error messgae

BadRequestError: ValidationFailed: Updating immutable properties is not allowed.

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 15, 2020

@jiasli @evelyn-ys for awareness

@houk-ms houk-ms merged commit 7361b99 into Azure:dev Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants