Replies: 2 comments
-
This seemingly straightforward topic requires more thoughts. A little bit history here. When MSAL code base was started 5+ years ago, we did define a highest level base exception Some people believe, all the observable exceptions arguably become part of the public API surface, therefore any new exception being raised, or an old exception no longer being raised, are both considered by them as a breaking change. We do not necessarily agree with that opinion, but we do want to minimize the need that our downstream consumers write code that unnecessarily couples with a lower-level library's exception. The rare time that we did explicitly define our exception (in our another library MSAL EX), was that we expect that its downstream app developer would need to catch it and can fully recover from it. Other than that, we consider it is less valuable to do a Back to this specific case, how MSAL handles those ID token validation is really just an implementation detail. At one point we seriously considered - and we still won't rule out that possibility - to switch to use a lower-level 3rd-party JWT library for token validation. And that library would probably emit different exceptions. If that happens, your existing |
Beta Was this translation helpful? Give feedback.
-
How about using If Azure CLI needs to do some additional recommendation for certain MSAL errors, catching Also, Azure CLI reports all errors through client telemetry. A generic |
Beta Was this translation helpful? Give feedback.
-
Currently MSAL uses the generic
RuntimeError
. This error is difficult to be distinguished from otherRuntimeError
, especially Python itself'sRuntimeError
:microsoft-authentication-library-for-python/msal/oauth2cli/oidc.py
Lines 75 to 77 in 9f78b6b
MSAL can introduce its own
MsalRuntimeError
so that Azure CLI can know this error comes from MSAL and do error handling at a centralized location.For example, Azure SDK defines
https://github.com/Azure/azure-sdk-for-python/blob/f843d16feb76a73d77e4fdee36cefc6646bd7c83/sdk/core/azure-core/azure/core/exceptions.py#L216
Azure CLI handles it at
https://github.com/Azure/azure-cli-pr/blob/6751048cd85921081e3d033624f6109d7d6a01ec/src/azure-cli-core/azure/cli/core/util.py#L99-L103
Beta Was this translation helpful? Give feedback.
All reactions