Skip to content

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Apr 11, 2020

Description
Fix #12957, #7989
If the computer name or C:\Windows\System32\drivers\etc\hosts 127.0.0.1 entries contain international characters (Unicode), Azure CLI fails with a nasty error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-_1mlo87m\azure-cli-core\azure\cli\core\_profile.py", line 1200, in _get_authorization_code_worker
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\socketserver.py", line 453, in __init__
    self.server_bind()
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\http\server.py", line 138, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\socket.py", line 673, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 10: invalid start byte

Login failed

This PR refines the error message to:

Please make sure there is no international (Unicode) character in the computer name or C:\Windows\System32\drivers\etc\hosts file's 127.0.0.1 entries. For more details, please see #12957

Testing Guide
Change computer name to a Unicode string like 测试 or add 127.0.0.1 测试 to C:\Windows\System32\drivers\etc\hosts. Run az login.

@yonzhan yonzhan added this to the S168 milestone Apr 12, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 12, 2020

add to S168

except socket.error as ex:
logger.warning("Port '%s' is taken with error '%s'. Trying with the next one", port, ex)
except UnicodeDecodeError:
logger.warning("Please make sure there is no international (Unicode) character in the computer name "
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious about that if we actually have international character in the compute name, the only way to get it passed is to rename the compute name ?

Copy link
Member Author

@jiasli jiasli Apr 16, 2020

Choose a reason for hiding this comment

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

The link does have instructions about how to bypass it: #12957

But using Unicode as a computer name is always a bad idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

@yonzhan yonzhan modified the milestones: S168, S169 - For Build Apr 18, 2020
break
except socket.error as ex:
logger.warning("Port '%s' is taken with error '%s'. Trying with the next one", port, ex)
except UnicodeDecodeError:
Copy link
Member

Choose a reason for hiding this comment

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

except UnicodeDecodeError: [](start = 8, length = 26)

make sure we handle this exception in MSAL too

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Member

@qianwens qianwens left a comment

Choose a reason for hiding this comment

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

:shipit:

@jiasli jiasli merged commit ad2a70f into Azure:dev Apr 20, 2020
@jiasli jiasli deleted the unicode branch April 20, 2020 05:26
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: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 10: invalid start byte

4 participants