Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

Cleanup incoming mailstore with corrupt documents #981

Closed
varac opened this issue Feb 14, 2017 · 5 comments
Closed

Cleanup incoming mailstore with corrupt documents #981

varac opened this issue Feb 14, 2017 · 5 comments

Comments

@varac
Copy link
Contributor

varac commented Feb 14, 2017

When recieving mails for an account with an expired key, documents in the incoming mailstore end up being corrupt and the useragent logs erors for those (see #908).
We need to clean them on wazokazi.

tuliocasagrande pushed a commit to pixelated/puppet-pixelated that referenced this issue Feb 14, 2017
@tuliocasagrande
Copy link
Collaborator

Please remember to remove the ignore pattern when this issue is done.

@tuliocasagrande
Copy link
Collaborator

A few couch queries that might help starting the work:

curl -s --netrc-file /etc/couchdb/couchdb.netrc '127.0.0.1:5984/_all_dbs' | jq .
curl -s --netrc-file /etc/couchdb/couchdb.netrc '127.0.0.1:5984/users/_all_docs?include_docs=true' | grep <username> | jq .
curl -s --netrc-file /etc/couchdb/couchdb.netrc '127.0.0.1:5984/user-<user_id>/_all_docs?include_docs=true' | jq .

@FrailWords
Copy link
Contributor

Created a merge request - https://0xacab.org/leap/bitmask-dev/merge_requests/85 for logging doc_id's which fail to decrypt.

@FrailWords
Copy link
Contributor

The fix that we have put in seems to be working, which is handle 'ValueError' in case of NODATA in the _process_decrypt_doc function. The behavior on this error is similar to the already existing code which ignores these messages from further syncing.

After fixing this problem, we are seeing a new error that seems to be the result of returning an empty array from this function instead of a string or a deferred as in other return statements in the same function. This is leading to the error in decrypting document as it is expecting a string or a buffer and not a list.

Below are the logs for this error -

Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.keymanager.openpgp] DEBUG [GNUPG:] NODATA 2
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: gpg: decrypt_message failed: eof
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.keymanager.openpgp] WARN Failed to decrypt: Failed to encrypt/decrypt: [GNUPG:] NODATA 2
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: gpg: decrypt_message failed: eof
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: .
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] ERROR _decrypt_doc: Error decrypting document with ID aeadc6a4-fd54-4784-abeb-
c591a40d014f
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] ERROR [Failure instance: Traceback: <class 'leap.bitmask.keymanager.errors.Dec
ryptError'>: Failed to encrypt/decrypt: [GNUPG:] NODATA 2
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: gpg: decrypt_message failed: eof
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:1126:_inlineCallbacks
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/failure.py:389:throwExceptionIntoGenerator
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/keymanager/__init__.py:591:decrypt_with_inactive_keys
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:1274:unwindGenerator
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: --- <exception caught here> ---
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:1128:_inlineCallbacks
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/keymanager/__init__.py:583:decrypt_with_inactive_keys
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: ]
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] INFO processing decrypted doc
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] ERROR Error while decrypting aeadc6a4-fd54-4784-abeb-c591a40d014f
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] ERROR No JSON object could be decoded
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] INFO adding message aeadc6a4-fd54-4784-abeb-c591a40d014f to local db
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: 2017-03-20 18:38:45 [leap.bitmask.mail.incoming.service] ERROR [Failure instance: Traceback (failure with no frames): <class 'twisted.i
nternet.defer.FirstError'>: FirstError[#1, [Failure instance: Traceback: <type 'exceptions.TypeError'>: must be string or buffer, not list
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:1184:gotResult
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:1174:_inlineCallbacks
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:434:errback
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:501:_startRunCallbacks
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: --- <exception caught here> ---
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py:588:_runCallbacks
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/mail/incoming/service.py:860:_add_message_locally
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/mail/mail.py:609:add_msg
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/mail/adaptors/soledad.py:870:get_msg_from_string
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/mail/adaptors/soledad.py:1192:_split_into_parts
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/share/python/pixelated-user-agent/src/leap.bitmask/src/leap/bitmask/mail/adaptors/soledad.py:1211:_parse_msg
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/lib/python2.7/email/__init__.py:57:message_from_string
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: /usr/lib/python2.7/email/parser.py:82:parsestr
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: ]]
Mar 20 18:38:45 pixelated pixelated-user-agent[26826]: ]

We need to speak with Leap folks about this error as this piece of code has a lot of comments which we don't know about.

@FrailWords
Copy link
Contributor

As the above error is not related to the original error in this card, we are moving this to 'pr in other project'. We have created a pull-request - https://0xacab.org/leap/bitmask-dev/merge_requests/87 for this.

leap-code-o-matic pushed a commit to leapcode/bitmask-dev that referenced this issue Mar 31, 2017
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 -
pixelated/pixelated-user-agent#908 &
pixelated/pixelated-user-agent#981 - to ignore
documents that have this problem and not have Soledad try to sync them
again and again.

with @deniscostadsc
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants