Closed
Description
Hello!
Describe the bug
Library raises this stack trace when a > 400 status is received
../.venv/lib/python3.12/site-packages/msal/application.py:632: in __init__
self.authority = Authority(
../.venv/lib/python3.12/site-packages/msal/authority.py:79: in __init__
openid_config = tenant_discovery(
../.venv/lib/python3.12/site-packages/msal/authority.py:222: in tenant_discovery
resp.raise_for_status()
../.venv/lib/python3.12/site-packages/msal/throttled_http_client.py:69: in raise_for_status
raise MsalServiceError("HTTP Error: {}".format(self.status_code))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = MsalServiceError('HTTP Error: 500'), args = ('HTTP Error: 500',)
kwargs = {}
def __init__(self, *args, **kwargs):
> super(MsalError, self).__init__(self.msg.format(**kwargs), *args)
E KeyError: 'error'
../.venv/lib/python3.12/site-packages/msal/exceptions.py:33: KeyError
To Reproduce
Steps to reproduce the behavior:
The closest is: https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/dev/sample/confidential_client_sample.py
And was reproduced in a test using requests_mock
Expected behavior
Should successfully raise a MsalServiceError i suppose
What you see instead
KeyError: 'error'
The MSAL Python version you are using
Paste the output of this
python -c "import msal; print(msal.__version__)"
1.32.3
Additional context
Seems to have been introduced here:
29d1ac1#diff-3ebc80b207eb5a4e4eae904208ad8d17cc8f7eaf23f5a7d82a185578f79898bfR61
This instantiation can't work
>>> from msal.exceptions import MsalServiceError
>>> MsalServiceError("HTTP Error: {}".format(401))