Skip to content
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

Some CLI commands fail due to issues with 'requests' v2.12.1 #1360

Closed
derekbekoe opened this issue Nov 17, 2016 · 7 comments
Closed

Some CLI commands fail due to issues with 'requests' v2.12.1 #1360

derekbekoe opened this issue Nov 17, 2016 · 7 comments
Labels

Comments

@derekbekoe
Copy link
Member

The 'requests' package was updated 2016-11-16 to version 2.12.1 - https://pypi.python.org/pypi/requests/.

In this update, version of urllib3 that is bundled with 'requests' was updated to 1.19.1 (also published 2016-11-16) - https://pypi.python.org/pypi/urllib3.

When the CLI and its dependencies are installed, the latest version of 'requests' is installed and it seems there's some incompatibility between the Azure SDK and the latest version of 'requests'.

I mention the Azure SDK but looks like adal also breaks for the same reason.

Current work around if you run into the error below is to downgrade 'requests' to 2.11.1.
e.g. pip install requests==2.11.1.

Related to Azure/azure-sdk-for-python#889.

//cc: @yugangw-msft, @johanste, @lmazuel

Full stace trace after an az vm list. When I downgrade 'requests', it works.

$ az vm list
'X509' object has no attribute '_x509'
Traceback (most recent call last):
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/main.py", line 33, in main
    cmd_result = APPLICATION.execute(args)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/core/application.py", line 139, in execute
    result = expanded_arg.func(params)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 274, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/command_modules/vm/custom.py", line 135, in list_vm
    return list(vm_list)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/msrest/paging.py", line 60, in __iter__
    for i in self.next():
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/msrest/paging.py", line 92, in next
    self._response = self._get_next(self.next_link)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/mgmt/compute/operations/virtual_machines_operations.py", line 618, in internal_paging
    request, header_parameters, **operation_config)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/msrest/service_client.py", line 167, in send
    session = self.creds.signed_session()
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/core/adal_authentication.py", line 22, in signed_session
    scheme, token = self._token_retriever()
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/core/_profile.py", line 239, in <lambda>
    username_or_sp_id, account[_TENANT_ID], resource)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/azure/cli/core/_profile.py", line 364, in retrieve_token_for_user
    token_entry = context.acquire_token(resource, username, _CLIENT_ID)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/authentication_context.py", line 106, in acquire_token
    return self._acquire_token(token_func)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/authentication_context.py", line 89, in _acquire_token
    return token_func(self)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/authentication_context.py", line 104, in token_func
    return token_request.get_token_from_cache_with_refresh(user_id)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/token_request.py", line 350, in get_token_from_cache_with_refresh
    return self._find_token_from_cache()
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/token_request.py", line 128, in _find_token_from_cache
    return self._cache_driver.find(cache_query)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/cache_driver.py", line 182, in find
    is_resource_tenant_specific)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/cache_driver.py", line 168, in _refresh_entry_if_necessary
    return self._refresh_expired_entry(entry)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/cache_driver.py", line 146, in _refresh_expired_entry
    token_response = self._refresh_function(entry, None)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/token_request.py", line 138, in _get_token_with_token_response
    return self._get_token_with_refresh_token(refresh_token, resource, None)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/token_request.py", line 342, in _get_token_with_refresh_token
    return self._oauth_get_token(oauth_parameters)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/token_request.py", line 113, in _oauth_get_token
    return client.get_token(oauth_parameters)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/adal/oauth2_client.py", line 260, in get_token
    verify=self._call_context.get('verify_ssl', None))
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/connectionpool.py", line 350, in _make_request
    self._validate_conn(conn)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/connectionpool.py", line 835, in _validate_conn
    conn.connect()
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/connection.py", line 330, in connect
    cert = self.sock.getpeercert()
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 324, in getpeercert
    'subjectAltName': get_subj_alt_name(x509)
  File "/Users/debekoe/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 166, in get_subj_alt_name
    cert = _Certificate(openssl_backend, peer_cert._x509)
AttributeError: 'X509' object has no attribute '_x509'
@mayurid
Copy link
Member

mayurid commented Nov 17, 2016

@derekbekoe: we need to revert this and update to pypi builds asap. lets discuss if you disagree.

@lmazuel
Copy link
Member

lmazuel commented Nov 17, 2016

Hi @derekbekoe
Didn't see this error currently in Travis, and the bug on our issue tracker is azure-storage (will tell them). We don't use ADAL and your stacktrace is coming from ADAL, I'm wondering if the "old" msrestazure has (by chance, not by design, Russian roulette) workarounded the issue. FYI @annatisch.
I will investigate in more details, we have old legacy packages (like ASM) which might be broken also. Thanks for mentioning me here.

@lmazuel
Copy link
Member

lmazuel commented Nov 17, 2016

I confirm I was able to use requests 2.12.1 with msrestazure.UserPasswordCredentials and azure-mgmt-resource. Don't know why...

@mayurid
Copy link
Member

mayurid commented Nov 17, 2016

@derekbekoe to provide details but his observation has been that it works on clean install. this was observed in machines that were upgraded,

@yugangw-msft
Copy link
Contributor

yugangw-msft commented Nov 17, 2016

Bug already reported at request package: https://github.com/kennethreitz/requests/issues/3701

@lmazuel
Copy link
Member

lmazuel commented Nov 17, 2016

In my test I updated a given 3.5 venv from requests 2.11.1 to 2.12.1 (Windows)

@derekbekoe
Copy link
Member Author

Closing issue and marking as FAQ due to https://github.com/kennethreitz/requests/issues/3701#issuecomment-262923046.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants