Skip to content

[Profile] Hotfix: Fix #15961: az login: UnboundLocalError: local variable 'token_entry' referenced before assignment - #15962

Merged
Jiashuo Li (jiasli) merged 2 commits into
Azure:releasefrom
evelyn-ys:refine_invalid_url
Nov 20, 2020
Merged

Jiashuo Li (jiasli) merged 2 commits into
Azure:releasefrom
evelyn-ys:refine_invalid_url

Conversation

@evelyn-ys

@evelyn-ys Yishi Wang (evelyn-ys) commented Nov 18, 2020

Copy link
Copy Markdown
Contributor

Description

Fix #15961 : az login: UnboundLocalError: local variable 'token_entry' referenced before assignment
In previous pr #15776 , Invalid Url is captured and handled, but other exceptions are hidden inappropriately.
This pr revokes previous change, InvalidUrl handling need further discussion.

Testing Guide

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There should be raise ex here

@yonzhan

Copy link
Copy Markdown
Collaborator

Profile

@yonzhan Yong Zhang (yonzhan) added this to the S179 milestone Nov 18, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A white space usually goes to the previous line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Comment on lines 133 to 134

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A browse won't be available on CI machine, so auth code flow won't be used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Appreciate for your help! That makes sense why CI fails....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

adal.AuthenticationContext will not be called, since SubscriptionFinder is using lambda _, _1, _2: mock_auth_context.

mock_auth_context can simply be created as a MagicMock().

Comment thread src/azure-cli/azure/cli/command_modules/profile/custom.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please make this a more general test case so that other errors can also be tested to avoid regression.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please print the error detail.

@jiasli Jiashuo Li (jiasli) changed the title {Profile} refine InvalidUrl when login [Profile] Fix #15961: az login: UnboundLocalError: local variable 'token_entry' referenced before assignment Nov 20, 2020
@jiasli
Jiashuo Li (jiasli) changed the base branch from dev to release November 20, 2020 02:01
@jiasli Jiashuo Li (jiasli) changed the title [Profile] Fix #15961: az login: UnboundLocalError: local variable 'token_entry' referenced before assignment [Profile] Hotfix: Fix #15961: az login: UnboundLocalError: local variable 'token_entry' referenced before assignment Nov 20, 2020
@qwordy

Copy link
Copy Markdown
Member

Hard to review. The changes are mixed up with unrelated changes.

@jiasli

Copy link
Copy Markdown
Contributor

Hard to review. The changes are mixed up with unrelated changes.

I have fixed the history.

@houk-ms Houk (houk-ms) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we explain more details about what's happening there in the pr description?

@jiasli

Copy link
Copy Markdown
Contributor

Could we explain more details about what's happening there in the pr description?

Will do a full analysis next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az login fails with UnboundLocalError: local variable 'token_entry' referenced before assignment

7 participants