Project

General

Profile

Bug #38130

UnicodeEncodeError at /dpark/parking/link/

Added by Nicolas Roche 14 days ago. Updated about 4 hours ago.

Status:
Nouveau
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
02 Dec 2019
Due date:
% Done:

0%

Patch proposed:
No
Planning:
No

Description

(à priori) Problème pour afficher le message d'erreur retourné par DPark.

Exception Type:     UnicodeEncodeError
Exception Value:     'ascii' codec can't encode character u'\xe9' in position 47: ordinal not in range(128)
Exception Location:     /usr/lib/python2.7/dist-packages/passerelle/contrib/dpark/models.py in call, line 205

args :
(<WSGIRequest: POST '/dpark/parking/link/?orig=demarches-montoulouse.eservices.toulouse-metropole.fr&algo=sha256&timestamp=2019-12-02T13%3A12%3A58Z&nonce=5fd51e97dd1566faf252dc13427f8278&signature=QWIxYrfc3anm/17kfE2ur%2BCkqJIdlEzqawQIEVpiPyE%3D'>,)

e :
UnicodeEncodeError('ascii', u"La valeur 'E-6-VMQN504M' ne respecte pas le sch\xe9ma XSD.", 47, 48, 'ordinal not in range(128)')

extras :
{'body': '\'{"lastname": "LANNELONGUE", "cardnumber": "", "firstnames": "VINCENT", "badgenumber": "", "filenumber": "E-6-VMQN504M", "nameid": "8da5dc154c544647ba33cc9d84db88b7"}\'',
 'exception': u"'ascii' codec can't encode character u'\\xe9' in position 47: ordinal not in range(128)",

Avec un peu de chance c'est déjà résolu par #37880

History

#1 Updated by Thomas Noël 14 days ago

L'erreur se produit ligne 205 :

    198     def call(self, operation, *args, **kwargs):
    199         client = get_client(self)
    200         proxy_service = client.create_service(SERVICE_BINDING, self.operation_url)
    201         bypass_erroneous_reply = kwargs.pop('bypass_erroneous_reply', False)
    202         try:
    203             reply = getattr(proxy_service, operation)(*args, **kwargs)
    204         except (WebFault, ) as exc:
    205             raise APIError('ServiceError: %s' % exc.message)
    206         except (Exception,) as exc:
    207             raise APIError('Error: %s' % exc.message)
    208         reply_code = getattr(reply, 'CodeRetour', None) or getattr(reply, 'Code_Retour', None)
    209         reply_message = getattr(reply, 'MessageRetour', None) or getattr(reply, 'Lib_Retour', None)
    210         if reply_code != '01' and not bypass_erroneous_reply:
    211             raise APIError(reply_message)
    212         return reply

C'est DPark qui n'est pas content et renvoie le message avec un encodage latin1. Il faudrait peut-être passer à %r sur les exc.message.

#2 Updated by Benjamin Dauvergne about 4 hours ago

force_text(exc.message , 'latin1', error='ignore')

Also available in: Atom PDF