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

TypeError: argument of type 'NoneType' is not iterable in msal_client.py #23483

Closed
micafer opened this issue Mar 11, 2022 · 4 comments
Closed
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@micafer
Copy link

micafer commented Mar 11, 2022

  • Azure.Identity:
  • 1.8.0:
  • Ubuntu 20.04:
  • Python 3.8:

Describe the bug

Sometimes when authenticating with ClientSecretCredential class I get this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/azure/identity/_internal/decorators.py", line 56, in wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/azure/identity/_credentials/user_password.py", line 58, in _request_token
    return app.acquire_token_by_username_password(
  File "/usr/local/lib/python3.8/dist-packages/msal/application.py", line 1417, in acquire_token_by_username_password
    user_realm_result = self.authority.user_realm_discovery(
  File "/usr/local/lib/python3.8/dist-packages/msal/authority.py", line 128, in user_realm_discovery
    resp.raise_for_status()
  File "/usr/local/lib/python3.8/dist-packages/azure/identity/_internal/msal_client.py", line 55, in raise_for_status
    if "error" in content or "error_description" in content:
TypeError: argument of type 'NoneType' is not iterable

To Reproduce
Steps to reproduce the behavior:
The error appears sometimes, I cannot reproduce the error with a fixed set ot steps.

Expected behavior

It should raise a ClientAuthenticationError with the correct error.

Additional context

I suggest to change this line:
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/azure/identity/_internal/msal_client.py#L53

from:

if ContentDecodePolicy.CONTEXT_NAME in self._response.context:

to:

if ContentDecodePolicy.CONTEXT_NAME in self._response.context and self._response.context[ContentDecodePolicy.CONTEXT_NAME]:
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 11, 2022
@azure-sdk azure-sdk added Azure.Identity Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. labels Mar 11, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 11, 2022
@catalinaperalta
Copy link
Member

Thanks for reporting this @micafer! We'll investigate and get back to you ASAP.

@catalinaperalta catalinaperalta added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-team-triage Workflow: This issue needs the team to triage. labels Mar 11, 2022
@xiangyan99
Copy link
Member

Thanks for reporting the issue. The fix has been merged and will be available in next release.

@xiangyan99 xiangyan99 added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Mar 15, 2022
@ghost
Copy link

ghost commented Mar 15, 2022

Hi @micafer. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost ghost removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Mar 15, 2022
@ghost
Copy link

ghost commented Mar 22, 2022

Hi @micafer, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Mar 22, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants