Gracefully handle failure to fetch h-x-app

This commit is contained in:
Danielle McLean 2023-08-16 11:47:00 +10:00
parent 03956637be
commit 8386f77d72
Signed by untrusted user: 00dani
GPG key ID: 52C059C3B22A753E

View file

@ -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