From 8386f77d72f318cece5cb0b1d4a3ed2ba6ada1c5 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 16 Aug 2023 11:47:00 +1000 Subject: [PATCH] Gracefully handle failure to fetch h-x-app --- lemonauth/views/tokens/list.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lemonauth/views/tokens/list.py b/lemonauth/views/tokens/list.py index 52e0760..1912937 100644 --- a/lemonauth/views/tokens/list.py +++ b/lemonauth/views/tokens/list.py @@ -1,3 +1,4 @@ +from requests import HTTPError from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import TemplateView from typing import Dict, Optional, Set @@ -20,10 +21,10 @@ class Client: self.id = client_id self.count = 0 self.scopes = set() - apps = mf2(self.id).to_dict(filter_by_type="h-x-app") try: + apps = mf2(self.id).to_dict(filter_by_type="h-x-app") self.app = apps[0]["properties"] - except IndexError: + except (HTTPError, IndexError): self.app = None