[16.0] Fetchmail_server_folder - fail with imaplib.IMAP4.abort: command: FETCH => System Error
Module
Fetchmail_server_folder
Describe the bug
Only starting to test the module and it's fail trying to retrive email from a GMail server.
To Reproduce
Affected versions: 16.0
Steps to reproduce the behavior:
- Enable the module
- Configure the folders to be fetch
- Click on "FETCH FOLDER NOW" buttont
Expected behavior The module should fetch and process the mails.
Current behaviour
2025-02-28 19:02:17,438 1 ERROR ikus odoo.addons.fetchmail_attach_from_folder.models.fetchmail_server_folder: Failed to fetch mail b'1' from server GMail Patrik
Traceback (most recent call last):
File "/usr/lib/python3.9/imaplib.py", line 1047, in _command_complete
typ, data = self._get_tagged_response(tag, expect_bye=logout)
File "/usr/lib/python3.9/imaplib.py", line 1165, in _get_tagged_response
self._check_bye()
File "/usr/lib/python3.9/imaplib.py", line 961, in _check_bye
raise self.abort(bye[-1].decode(self._encoding, 'replace'))
imaplib.IMAP4.abort: System Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 188, in retrieve_imap_folder
self.apply_matching(connection, msgid)
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 227, in apply_matching
message_org = self.fetch_msg(connection, msgid)
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 269, in fetch_msg
result, msgdata = connection.fetch(msgid, "(RFC822)")
File "/usr/lib/python3.9/imaplib.py", line 548, in fetch
typ, dat = self._simple_command(name, message_set, message_parts)
File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib/python3.9/imaplib.py", line 1049, in _command_complete
raise self.abort('command: %s => %s' % (name, val))
imaplib.IMAP4.abort: command: FETCH => System Error
2025-02-28 19:02:17,445 1 ERROR ikus odoo.addons.fetchmail_attach_from_folder.models.fetchmail_server_folder: Failed to fetch mail b'2' from server GMail Patrik
Traceback (most recent call last):
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 188, in retrieve_imap_folder
self.apply_matching(connection, msgid)
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 227, in apply_matching
message_org = self.fetch_msg(connection, msgid)
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 269, in fetch_msg
result, msgdata = connection.fetch(msgid, "(RFC822)")
File "/usr/lib/python3.9/imaplib.py", line 548, in fetch
typ, dat = self._simple_command(name, message_set, message_parts)
File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib/python3.9/imaplib.py", line 1045, in _command_complete
self._check_bye()
File "/usr/lib/python3.9/imaplib.py", line 961, in _check_bye
raise self.abort(bye[-1].decode(self._encoding, 'replace'))
imaplib.IMAP4.abort: System Error
2025-02-28 19:02:17,445 1 ERROR ikus odoo.addons.fetchmail_attach_from_folder.models.fetchmail_server_folder: Failed to fetch mail b'3' from server GMail Patrik
Traceback (most recent call last):
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 188, in retrieve_imap_folder
self.apply_matching(connection, msgid)
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 227, in apply_matching
message_org = self.fetch_msg(connection, msgid)
File "/mnt/extra-addons/fetchmail_attach_from_folder/models/fetchmail_server_folder.py", line 269, in fetch_msg
result, msgdata = connection.fetch(msgid, "(RFC822)")
File "/usr/lib/python3.9/imaplib.py", line 548, in fetch
typ, dat = self._simple_command(name, message_set, message_parts)
File "/usr/lib/python3.9/imaplib.py", line 1230, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib/python3.9/imaplib.py", line 1045, in _command_complete
self._check_bye()
File "/usr/lib/python3.9/imaplib.py", line 961, in _check_bye
raise self.abort(bye[-1].decode(self._encoding, 'replace'))
imaplib.IMAP4.abort: System Error
Additional context
Never mind,
Suddently, I can't reproduce the problem.
Sorry for the noise
Finnaly the problem started again.
I notice the issue arise when defining an "archive" folder option. Since the expunge is execute on every delete operation and not at the very end. The message id return by the fetch doesn't make any sens.
I would recommand to modify the implementation to either:
- Process the message ids from last to first.
- Execute expunge at the end
Solved in this commit: 17ba6bc9c540f09437bddf89a3a105a3853d4165
Thank you !