-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} az login: Add error handling when finding subscriptions #15776
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
Conversation
|
Core |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with UnknownError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with before
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
Fix #15836 |
b2e09ad to
bc51668
Compare
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 loginFix #15836
Testing Guide
see the unit tests in test_profile.py