Skip to content

Conversation

@evelyn-ys
Copy link
Member

@evelyn-ys evelyn-ys commented Nov 3, 2020

Description

This PR is a supplement to #15574 , also works as a part of fixing the none-actionable issues in #14981
Fix the left uncaught errors with az login

Fix #15836

Testing Guide
see the unit tests in test_profile.py

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 3, 2020

Core

@yonzhan yonzhan requested a review from zhoxing-ms November 3, 2020 06:57
Comment on lines 824 to +831
Copy link
Member Author

@evelyn-ys evelyn-ys Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some weird cases(CX upgrade or degrade MGMT_RESOURCE_SUBSCRIPTIONS themselves, I guess.), get_client_class will fail and return None. If not verified, line 829 will throw TypeError: _NoneType_ object is not callable.
@jiasli Any idea on the real reason?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with it, currently.

But we may need go deeper to see what are the exact reasons that cause the errrors and provide the corresponding suggestions. Because our goal is to resolve all the CLIInternalErrors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because get_client_class returned None. In such case azure-mgmt-resource SDK is somehow missing.

get_client_class should actually raise an Exception instead of returning None. This is a design flaw and need further discussion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases from the telemetry, CX tried acquiring token from strange authority url. I don't know how it happens, maybe they use private cloud misconfigured. I just add catch logic here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users can register their own cloud with az cloud register and provide invalid URL for AAD. Consider mark that as a UserFault.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually use UnknownError, which is a subclass of UserFault

@evelyn-ys evelyn-ys requested a review from houk-ms November 5, 2020 06:20
Copy link
Contributor

@houk-ms houk-ms Nov 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we define a new error type InvalidURL error. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced with UnknownError

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with before

Comment on lines 824 to +831
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with it, currently.

But we may need go deeper to see what are the exact reasons that cause the errrors and provide the corresponding suggestions. Because our goal is to resolve all the CLIInternalErrors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use lazy import to avoid performance impact. See #13843

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users can register their own cloud with az cloud register and provide invalid URL for AAD. Consider mark that as a UserFault.

Comment on lines 879 to 883
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider unifying the code in one place to avoid duplication.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the acquire_token fuction diffs for each scenario, the debug log and error msg are also customized. So I didn't unify the code.

Comment on lines 122 to 125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean status and reason can be missing? Kindly provide more context.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. The HttpError.response returned somehow doesn't have status and reason attribute. In that case, I use the whole response as err_msg

@evelyn-ys evelyn-ys requested a review from jiasli November 10, 2020 09:36
@haroldrandom
Copy link
Contributor

haroldrandom commented Nov 10, 2020

Fix #15836

@evelyn-ys evelyn-ys merged commit d167cb7 into Azure:dev Nov 11, 2020
@evelyn-ys evelyn-ys deleted the err_improvement branch November 11, 2020 08:42
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.

Issue in az network vpn-connection show

5 participants