Skip to content
Snippets Groups Projects
Commit 9b8d2ae7 authored by Andy Craze's avatar Andy Craze
Browse files

Handle invalid JSON returned by nodeinfo endpoint

Fixes #1057
parent d4a256b2
No related branches found
No related tags found
No related merge requests found
Pipeline #11806 failed with stages
in 47 seconds
import json
import logging
from django.conf import settings
......@@ -18,6 +19,9 @@ from . import nodeinfo
NODEINFO_2_CONTENT_TYPE = "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8" # noqa
logger = logging.getLogger(__name__)
class AdminSettings(preferences_viewsets.GlobalPreferencesViewSet):
pagination_class = None
permission_classes = [oauth_permissions.ScopePermission]
......@@ -44,7 +48,11 @@ class NodeInfo(views.APIView):
authentication_classes = []
def get(self, request, *args, **kwargs):
data = nodeinfo.get()
try:
data = nodeinfo.get()
except ValueError:
logger.warn('nodeinfo returned invalid json')
data = {}
return Response(data, status=200, content_type=NODEINFO_2_CONTENT_TYPE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment