Projet

Général

Profil

Bug #83342

astech: crash « Object of type bytes is not JSON serializable » sur une APIError

Ajouté par Sentry Io il y a 6 mois. Mis à jour il y a 6 mois.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
10 novembre 2023
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Non
Planning:
Non

Description

https://sentry.entrouvert.org/entrouvert/publik/issues/116494/

Parce qu'on utilise response.content (bytes) au lieu de response.text (str) on a ce crash quand on emet une APIError dans le connecteur AS-TECH :

APIError: AS-TECH response: 401 Unauthorized
  File "passerelle/utils/jsonresponse.py", line 128, in api
    resp = f(*args, **kwargs)
  File "passerelle/views.py", line 568, in perform
    result = self.endpoint(request, **params)
  File "passerelle/apps/astech/models.py", line 283, in authorization
    return {'data': self.get_authorization()}
  File "passerelle/apps/astech/models.py", line 206, in get_authorization
    authorization = self.call_json('post', url, params=params, json={'application': 'interfaceCitoyenne'})
  File "passerelle/apps/astech/models.py", line 165, in call_json
    raise APIError(

TypeError: Object of type bytes is not JSON serializable
(13 additional frame(s) were not displayed)
...
  File "json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "passerelle/utils/jsonresponse.py", line 43, in default
    return super().default(o)
  File "django/core/serializers/json.py", line 105, in default
    return super().default(o)
  File "json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '

Révisions associées

Révision 0a280341 (diff)
Ajouté par Thomas Noël il y a 6 mois

astech: don't use bytes in APIError content (#83342)

Historique

#1

Mis à jour par Thomas Noël il y a 6 mois

  • Projet changé de Suivi des traces à Passerelle
  • Assigné à mis à Thomas Noël
#2

Mis à jour par Robot Gitea il y a 6 mois

  • Statut changé de Nouveau à Solution proposée

Thomas NOËL (tnoel) a ouvert une pull request sur Gitea concernant cette demande :

#3

Mis à jour par Robot Gitea il y a 6 mois

  • Statut changé de Solution proposée à Solution validée

Serghei Mihai (smihai) a approuvé une pull request sur Gitea concernant cette demande :

#4

Mis à jour par Robot Gitea il y a 6 mois

  • Statut changé de Solution validée à Résolu (à déployer)

Thomas NOËL (tnoel) a mergé une pull request sur Gitea concernant cette demande :

#5

Mis à jour par Transition automatique il y a 6 mois

  • Statut changé de Résolu (à déployer) à Solution déployée
#6

Mis à jour par Transition automatique il y a 4 mois

Automatic expiration

Formats disponibles : Atom PDF