Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to fetch messages UID '238'.Server responded: OK [] #429

Closed
StarsoftAnalysis opened this issue Jan 24, 2017 · 5 comments
Closed

failed to fetch messages UID '238'.Server responded: OK [] #429

StarsoftAnalysis opened this issue Jan 24, 2017 · 5 comments

Comments

@StarsoftAnalysis
Copy link

I'm getting this error on a new server, syncing existing mailboxes to empty local Maildirs. On the old server, the same configuration (with offlineimap 6) runs without errors.

Three users get one or two emails rejected in this way; the other half-dozen users are fine.

Local IMAP is handled by dovecot.

General information

  • system/distribution (with version): Debian 8, Linux 3.16.0-4-amd64 Missing master commit #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux
  • offlineimap version (offlineimap -V): offlineimap v7.0.12, imaplib2 v2.55 (bundled)
  • Python version: Python v2.7.9
  • server name or domain: server2
  • CLI options: offlineimap -o -l offlineimap.log

Configuration file offlineimaprc

[general]
metadata = ~/offlineimap-meta
accounts = 1and1
pythonfile = /usr/local/bin/readnetrc.py  # (provides get_password() and get_username()
ui = Basic
ignore-readonly = no
[Account 1and1]
localrepository = LocalIMAP
remoterepository = RemoteIMAP1and1
autorefresh = 5
quick = 10
[Repository LocalIMAP]
type = IMAP
ssl = no
remotehost = localhost
remotepasseval = get_password("localhost")
remoteusereval = get_username("localhost")
nametrans = lambda foldername: re.sub ('^Junk E-mail$', 'Spam',
                                re.sub ('^Deleted Items$', 'Trash',
                           foldername))
folderfilter = lambda foldername: foldername not in ['Spam', 'Trash']
[Repository RemoteIMAP1and1]
type = IMAP
remotehost = imap.1and1.co.uk
ssl = yes
sslcacertfile=/etc/ssl/certs/ca-certificates.crt
remotepasseval = get_password("imap.1and1.co.uk")
 remoteusereval = get_username("imap.1and1.co.uk")
idlefolders = ['INBOX']
maxconnections = 2
holdconnectionopen = yes
keepalive = 60
subscribedonly = no
nametrans = lambda foldername: re.sub ('^Spam$', 'Junk E-mail',
                               re.sub ('^Trash$', 'Deleted Items',
                           foldername))
folderfilter = lambda foldername: foldername not in ['Junk E-mail',
        'Deleted Items']

pythonfile (if any)

import netrc
def get_username(host):
        """Get username for host from ~.netrc"""
        info = netrc.netrc()    # default is $HOME/.netrc
        login, account, password = info.authenticators(host)
        return login
def get_password(host):
        """Get password for host from ~.netrc"""
        info = netrc.netrc()    # default is $HOME/.netrc
        login, account, password = info.authenticators(host)
        return password

Logs, error

ERROR: Exceptions occurred during the run!
ERROR: IMAP server 'RemoteIMAP1and1' failed to fetch messages UID '238'.Server responded: OK []
Traceback:
  File "/usr/local/lib/python2.7/dist-packages/offlineimap/folder/Base.py", line 839, in copymessageto
    message = self.getmessage(uid)
  File "/usr/local/lib/python2.7/dist-packages/offlineimap/folder/IMAP.py", line 308, in getmessage
    data = self._fetch_from_imap(str(uid), 2)
  File "/usr/local/lib/python2.7/dist-packages/offlineimap/folder/IMAP.py", line 770, in _fetch_from_imap
    raise OfflineImapError(reason, severity)

Steps to reproduce the error

  • run 'offlineimap' !
@nicolas33 nicolas33 added the bug label Jan 24, 2017
@nicolas33
Copy link
Member

nicolas33 commented Jan 24, 2017

ERROR: IMAP server 'RemoteIMAP1and1' failed to fetch messages UID '238'.Server responded: OK []

That's weird. The response is declared OK but we could find no data in it. Please, try to add a debug statement and check the result (offlineimap/folder/IMAP.py, lines 761-762):

if res_type == 'OK':
    print(data) # <--- Added
    data = [res for res in data if not isinstance(res, str)]

@StarsoftAnalysis
Copy link
Author

Thanks for the reply. Printing 'data' for all emails overwhelmed the terminal with output, so I added this

if res_type == 'OK':
    print("******** uids: %s" % uids)
    if uids == '238':
        print(data)
    data = [res for res in data if not isinstance(res, str)]

and got this output

******** uids: 238
['5 (UID 238 BODY[] "6")']
ERROR: IMAP server 'RemoteIMAP1and1' failed to fetch messages UID '238'.Server responded: OK []

Does that help?

nicolas33 added a commit that referenced this issue Jan 24, 2017
… UID FETCH

Github-ref: #429
Signed-off-by: Nicolas Sebrecht <[email protected]>
@nicolas33
Copy link
Member

Yes. There is no body because the server could not find a mail with UID 238.

I wonder this is happening because of a race condition on the server or the client is trying to upload an invalid mail and we failed at reporting this (if we got any report from the server about that).

I wrote a patch to improve the error message in this case.

@nicolas33
Copy link
Member

I wonder this is happening because of a race condition on the server or the client is trying to upload an invalid mail and we failed at reporting this (if we got any report from the server about that).

I'm wrong here. The reason why this fails is unkown. Offlineimap was told the server has UID 238 but the server could not provide the body.

@nicolas33 nicolas33 added enhancement and removed bug labels Jan 24, 2017
@StarsoftAnalysis
Copy link
Author

Thanks. I've applied the update, and at least get better error messages now.

It's definitely nothing to do with uploading emails because nothing is being changed locally.

I went through the offending folder on the remote server (Trash) on the remote server, and found an email with 'Unknown sender', no subject, and no content. I deleted that, and the error message has gone away.

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants