Fixed crashing nodeinfo fetching when remote answers with invalid JSON

environments/review-front-deve-otr6gc/deployments/1920
Eliot Berriot 2019-06-24 16:21:06 +02:00
rodzic 62939d6826
commit d39edae061
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
3 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -190,7 +190,7 @@ def update_domain_nodeinfo(domain):
now = timezone.now() now = timezone.now()
try: try:
nodeinfo = {"status": "ok", "payload": fetch_nodeinfo(domain.name)} nodeinfo = {"status": "ok", "payload": fetch_nodeinfo(domain.name)}
except (requests.RequestException, serializers.serializers.ValidationError) as e: except (requests.RequestException, serializers.serializers.ValidationError, ValueError) as e:
nodeinfo = {"status": "error", "error": str(e)} nodeinfo = {"status": "error", "error": str(e)}
service_actor_id = common_utils.recursive_getattr( service_actor_id = common_utils.recursive_getattr(

Wyświetl plik

@ -371,7 +371,7 @@ class ManageDomainViewSet(
def perform_create(self, serializer): def perform_create(self, serializer):
domain = serializer.save() domain = serializer.save()
federation_tasks.update_domain_nodeinfo.delay(domain_name=domain.name) federation_tasks.update_domain_nodeinfo(domain_name=domain.name)
@rest_decorators.action(methods=["get"], detail=True) @rest_decorators.action(methods=["get"], detail=True)
def nodeinfo(self, request, *args, **kwargs): def nodeinfo(self, request, *args, **kwargs):

Wyświetl plik

@ -63,7 +63,7 @@ def test_domain_detail(factories, superuser_api_client):
def test_domain_create(superuser_api_client, mocker): def test_domain_create(superuser_api_client, mocker):
update_domain_nodeinfo = mocker.patch( update_domain_nodeinfo = mocker.patch(
"funkwhale_api.federation.tasks.update_domain_nodeinfo.delay" "funkwhale_api.federation.tasks.update_domain_nodeinfo"
) )
url = reverse("api:v1:manage:federation:domains-list") url = reverse("api:v1:manage:federation:domains-list")
response = superuser_api_client.post(url, {"name": "test.federation"}) response = superuser_api_client.post(url, {"name": "test.federation"})