-
Notifications
You must be signed in to change notification settings - Fork 502
Conversation
This looks good 👍 Maybe we can catch all socket.* errors ( |
I think these should never be raised by imaplib. From 3.3 on all these are subclasses of |
I'm not sure what python version paperless aims to support. If >= 3.3 then |
I can't find any sources right now but I thought that virtually all linux distributions are on python3 >= 3.3. As far as I see python 3.0-3.3 is end of life, so assuming python >= 3.3 seems unproblematic to me. |
When something goes wrong with the imaplib.IMAP4_SSL connection (like the host is temporarely down or the DNS does not resolve) it generates an OSError which is currently not catched and handled. Now OSErrors are translated to MailFetcherErrors which get logged and the IMAP connection is retried in the next IMAP check. Fixes #474
Additionally, |
Should this include a test? I'm not super sure how to test that, besides spinning up a IMAP server and then manipulating the connection, which seems "overkill". |
You could use a |
To me that seems to stray into "adding a test for adding a test" territory, but if you you it would be worth it I can add it. |
I don't think a test is necessary for that. A wider check testing that any errors during the consumption doesn't crash it would be better IMO. But that's not really the scope of that PR. |
My point was just, that writing a test would be possible without an imap server. I agree that for this exception handler, probably no test is necessary, if we don't aim for 100% test coverage. |
Honestly, I'd like to aim for 100% test coverage (or at least explicitly set With all that said though, I'm a pragmatist when it comes to this project and if there's consensus here, that this PR should be merged, then I'll hit the Big Green Button. @ovv, @MasterofJOKers, @syntonym, what say you? |
I agree with you @danielquinn , tests would be better but we should also make sure that it doesn't drive contribution away. IMO a good starting point is to require tests for new features and important bugfixes. In this case I don't think a test would add anything. |
While test coverage is important I think even 100% of source lines covered by unit tests is "not enough". Adding a unit tests which throws a As this PR is of low impact I'd advocate for merging it while I'm looking into writing some wider unittests covering the consumption process as ovv suggested. |
Thanks for all the input guys. I'll merge this now. |
imaplib.IMAP4_SSL raises a socket.gaierror when something goes wrong with connecting
to PAPERLESS_CONSUME_MAIL_HOST. Later MailFetcherErrors are excepted, but socket.gaierror
are not, so instead raise a MailFetcherError. Because socket.gaierrors can have numerous
reasons (gaierror wraps EAI_* errors from getaddrinfo, so see man getaddrinfo EAI_*),
include the error description in the exception.
Fixes #474