Projet

Général

Profil

0001-dataviz-ignore-bad-statistics-provider-result-71963.patch

Thomas Noël, 08 décembre 2022 16:32

Télécharger (1,31 ko)

Voir les différences:

Subject: [PATCH] dataviz: ignore bad statistics provider result (#71963)

 combo/apps/dataviz/utils.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
combo/apps/dataviz/utils.py
1
import json
2

  
1 3
import django
2 4
from django.conf import settings
3 5

  
......
23 25
        for site_key, site_dict in sites.items():
24 26
            response = requests.get(
25 27
                url,
28
                allow_redirects=False,
26 29
                timeout=5,
27 30
                remote_service=site_dict if provider in settings.KNOWN_SERVICES else {},
28 31
                without_user=True,
......
31 34
            if response.status_code != 200:
32 35
                continue
33 36

  
34
            result = response.json()
37
            try:
38
                result = response.json()
39
            except json.JSONDecodeError:
40
                continue
35 41
            if isinstance(result, dict):
36 42
                result = result['data']  # detect new api
37 43

  
38
-