[Feature Request] Raise MSAL specific error, instead of base error `ValueError`, `RuntimeError`
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- authentication
Piste de recherche
Start by reading the linked discussion from pull request #443 and the Azure CLI error handling examples in the linked files. The issue proposes MSAL-specific exception types derived from base Python errors, such as AuthorityError or MsalValueError, but leaves the API and set of errors to define. Done means MSAL raises identifiable errors for these scenarios so callers can handle them centrally; the thread has had no comment for over three years.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Originally from https://github.com/AzureAD/microsoft-authentication-library-for-python/pull/443#discussion_r895288236
Currently, MSAL raises Python's base error ValueError for scenarios such as tenant validation failure. Azure CLI can't really tell whether the error comes from MSAL or other places if we use a centralized error handling logic.
Now we handle all PersistenceError (https://github.com/AzureAD/microsoft-authentication-extensions-for-python/pull/108) in a centralized place:
elif isinstance(ex, PersistenceError):
# errno is already in strerror. str(ex) gives duplicated errno.
az_error = azclierror.CLIInternalError(ex.strerror)
if ex.errno == 0:
az_error.set_recommendation(
"Please report to us via Github: https://github.com/Azure/azure-cli/issues/20278")
elif ex.errno == -2146893813:
az_error.set_recommendation(
"Please report to us via Github: https://github.com/Azure/azure-cli/issues/20231")
elif ex.errno == -2146892987:
az_error.set_recommendation(
"Please report to us via Github: https://github.com/Azure/azure-cli/issues/21010")
This saves us from the necessity of capturing the error and handing it in all "joints" with MSAL.
But for this ValueError, we will have to capture it everywhere when MSAL interaction is made:
result = self._msal_app.acquire_token_interactive(
scopes, prompt='select_account', port=8400 if self._is_adfs else None,
success_template=success_template, error_template=error_template, **kwargs)
result = self._msal_app.acquire_token_by_device_flow(flow, **kwargs) # By default it will block
If we don't handle the error, the raw exception with traceback is shown, like in https://github.com/Azure/azure-cli/issues/20507, which is of course bad user experience.
I am thinking maybe MSAL can do the same for this ValueError (and other base error types raised) and create new error types which inherent from ValueError, such as AuthorityError, MsalValueError.
- Langage dominant
- Python
- Étoiles
- 971
- Forks
- 223
- Merge moyen
- 13 h 48 min
- PR mergées (30 j)
- 2
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de AzureAD/microsoft-authentication-library-for-python
-
needs attention untriaged
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
AzureSDK bug P1
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
http_client docstring does not say that timeout, verify and proxies only configure the default sessionPeut-être pris @HardMax71 l’a pris il y a 38 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 25/100
-
[Bug] The built-in retry never retries the token POST: HTTPAdapter(max_retries=1) keeps urllib3's default allowed_methodsPeut-être pris @HardMax71 l’a pris il y a 44 jours. Ouvertebug untriaged
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
AzureAD/microsoft-authentication-library-for-python#957 · 3 commentaires ·
-
public-client untriaged
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
Toutes les issues de AzureAD/microsoft-authentication-library-for-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
webrecorder/warcio#209 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Jeffy123-zhu/logspecter#20 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour