server-tools icon indicating copy to clipboard operation
server-tools copied to clipboard

[16.0] Fetchmail_server_folder - fail with imaplib.IMAP4.abort: command: FETCH => System Error

Open ikus060 opened this issue 10 months ago • 4 comments

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:

  1. Enable the module
  2. Configure the folders to be fetch
  3. Click on "FETCH FOLDER NOW" buttont

Image

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

ikus060 avatar Feb 28 '25 19:02 ikus060

Never mind,

Suddently, I can't reproduce the problem.

Sorry for the noise

ikus060 avatar Feb 28 '25 19:02 ikus060

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:

  1. Process the message ids from last to first.
  2. Execute expunge at the end

ikus060 avatar Mar 01 '25 15:03 ikus060

Solved in this commit: 17ba6bc9c540f09437bddf89a3a105a3853d4165

NL66278 avatar May 01 '25 10:05 NL66278

Thank you !

ikus060 avatar May 01 '25 11:05 ikus060