From 606289c43713414b0b9ffdb4f233362a8f214243 Mon Sep 17 00:00:00 2001 From: Sriram Viswanathan Date: Fri, 17 Mar 2017 17:39:46 -0300 Subject: [bug] Log error in case JSON parsing fails for decrypted doc In addition to the UnicodeError exception in _process_decrypted_doc function, we have added ValueError to the exception list so that we can catch any error in JSON parsing, specially a 'NODATA' error that we were getting with some of the emails. This is in reference to issues - https://github.com/pixelated/pixelated-user-agent/issues/908 & https://github.com/pixelated/pixelated-user-agent/issues/981 - to ignore documents that have this problem and not have Soledad try to sync them again and again. with @deniscostadsc --- src/leap/bitmask/mail/incoming/service.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/mail/incoming/service.py b/src/leap/bitmask/mail/incoming/service.py index e1dde02..e2baadb 100644 --- a/src/leap/bitmask/mail/incoming/service.py +++ b/src/leap/bitmask/mail/incoming/service.py @@ -337,13 +337,14 @@ class IncomingMail(Service): "1" if success else "0") return self._process_decrypted_doc(doc, decrdata) - def log_doc_id_and_raise_exception(failure): + def log_doc_id_and_call_errback(failure): logger.error( - '_decrypt_doc: Error decrypting document with ID %s' % doc.doc_id) + '_decrypt_doc: Error decrypting document with ' + 'ID %s' % doc.doc_id) self._errback(failure) d = self._keymanager.decrypt(doc.content[ENC_JSON_KEY], self._userid) - d.addErrback(log_doc_id_and_raise_exception) + d.addErrback(log_doc_id_and_call_errback) d.addCallback(process_decrypted) d.addCallback(lambda data: (doc, data)) return d @@ -368,9 +369,9 @@ class IncomingMail(Service): # the deferreds that would process an individual document try: msg = json_loads(data) - except UnicodeError as exc: + except (UnicodeError, ValueError) as exc: logger.error("Error while decrypting %s" % (doc.doc_id,)) - logger.exception(exc) + logger.error(str(exc)) # we flag the message as "with decrypting errors", # to avoid further decryption attempts during sync -- cgit v1.2.3