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

UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: MKBG20 UID FETCH 0 (BODY.PEEK[]) #336

Closed
khatchad opened this issue May 24, 2016 · 19 comments

Comments

@khatchad
Copy link

This v1.0 template stands in .github/.

General informations

  • OfflineIMAP version: 6.7.0
  • server name or domain: email1.citytech.cuny.edu
  • CLI options: -f Cabinet
[general]
accounts = CityTech
socktimeout = 10
ui = basic
[mbnames]
enabled = yes
filename = $HOME/.mutt/accounts/rkhatchadourian@citytech.cuny.edu/mailboxes
header = "mailboxes "
# peritem = "+%(accountname)s/%(foldername)s"
peritem = "+%(foldername)s"
sep = " "
footer = "\n"
incremental = yes
[Account CityTech]
localrepository = Local
remoterepository = Remote
autorefresh = 5
quick = 10
newmail_hook = lambda: os.system("osascript -e 'display notification \"New Mail\"'")
status_backend = sqlite

[Repository Local]
type = Maildir
localfolders = ~/.mail/rkhatchadourian@citytech.cuny.edu

[Repository Remote]
type = IMAP
remotehost = email1.citytech.cuny.edu

ssl = no

remoteuser = rkhatchadourian
remotepassfile = ~/.offlineimap.citytech.password
The pythonfile file goes here (if any). REMOVE PRIVATE DATA.

Log error

OfflineIMAP 6.7.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
*** Processing account CityTech
Establishing connection to email1.citytech.cuny.edu:143
Syncing Cabinet: IMAP -> Maildir
Copy message 0 (1 of 6) Remote:Cabinet -> Local
Copy message 12500 (2 of 6) Remote:Cabinet -> Local
ERROR: Copying message 0 [acc: CityTech]
  UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: DLBH13 UID FETCH 0 (BODY.PEEK[])

Copy message 17271 (3 of 6) Remote:Cabinet -> Local
Thread 'Copy message from Remote:Cabinet' terminated with exception:
Traceback (most recent call last):
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/threadutil.py", line 163, in run
    Thread.run(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/folder/Base.py", line 787, in copymessageto
    message = self.getmessage(uid)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/folder/IMAP.py", line 285, in getmessage
    data = self._fetch_from_imap(str(uid), 2)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/folder/IMAP.py", line 696, in _fetch_from_imap
    res_type, data = imapobj.uid('fetch', uids, query)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/imaplib2.py", line 1221, in uid
    return self._simple_command('UID', command, *args, **kw)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/imaplib2.py", line 1691, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/imaplib2.py", line 1444, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))
error: UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: DLBH13 UID FETCH 0 (BODY.PEEK[])



Last 2 debug messages logged for Copy message from Remote:Cabinet prior to exception:
thread: Register new thread 'Copy message from Remote:Cabinet' (account 'CityTech')
imap:   57:49.71 Copy message from Remote:Cabinet last 20 log messages:
ERROR: Exceptions occurred during the run!
ERROR: Copying message 0 [acc: CityTech]
  UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: DLBH13 UID FETCH 0 (BODY.PEEK[])


Traceback:
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/folder/Base.py", line 787, in copymessageto
    message = self.getmessage(uid)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/folder/IMAP.py", line 285, in getmessage
    data = self._fetch_from_imap(str(uid), 2)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/folder/IMAP.py", line 696, in _fetch_from_imap
    res_type, data = imapobj.uid('fetch', uids, query)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/imaplib2.py", line 1221, in uid
    return self._simple_command('UID', command, *args, **kw)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/imaplib2.py", line 1691, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/usr/local/Cellar/offlineimap/6.7.0/libexec/offlineimap/imaplib2.py", line 1444, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

Steps to reproduce the error

  • Run offlineimap -f Cabinet

Regression

I believe I upgraded to a new offlineimap today via brew upgrade. It was working as of yesterday before the upgrade.

@nicolas33
Copy link
Member

That's weird. The UID = 0 is already discarded in the code.

I wonder there are side effects due to a corrupted Maildir/cache. Please, check both are valid (no email with UID set to zero).

@khatchad
Copy link
Author

I wonder there are side effects due to a corrupted Maildir/cache. Please, check both are valid (no email with UID set to zero).

@nicolas33 How do I do that?

@khatchad
Copy link
Author

@nicolas33 Also, it looks it's copying from remote.

@nicolas33
Copy link
Member

UID must be > 0 as per RFC 3501. If the server returns 0 for a UID value, it has implementation issues.

@nicolas33
Copy link
Member

Please, check both are valid (no email with UID set to zero).

Explore the directories cur and new for the Cabinet folder in the Maildir and check for the values of U= in the filenames.

For the cache, open the sqlite database and check the values in there. You might want to convert it to text format if this helps.

@khatchad
Copy link
Author

@nicolas33:

Explore the directories cur and new for the Cabinet folder in the Maildir and check for the values of U= in the filenames.

Checked. Don't see any.

For the cache, open the sqlite database and check the values in there. You might want to convert it to text format if this helps.

Checked. I queried the database and didn't find any. Is it possible to be coming from the server?

@khatchad
Copy link
Author

UID must be > 0 as per RFC 3501. If the server returns 0 for a UID value, it has implementation issues.

@nicolas33, is there an easy way to test that?

@nicolas33
Copy link
Member

Yes, the wrong UID might come from the server. You might run a manual IMAP session to check. You'll get help how to do that here: http://www.offlineimap.org/server/imap/error/2016/01/27/error-no-such-number.html

@khatchad
Copy link
Author

khatchad commented May 25, 2016

@nicolas33, OK, this is what I got:

a010 fetch 1:1050 (uid)
* 1 FETCH (UID 0)
* 2 FETCH (UID 20)
...

What do you think?

@nicolas33 nicolas33 added enhancement and removed bug labels May 25, 2016
@nicolas33
Copy link
Member

nicolas33 commented May 25, 2016

The server is not IMAP compliant.

However, we might give a better warning and ignore this UID number.

@nicolas33
Copy link
Member

Done: f00cbee

@khatchad
Copy link
Author

Thanks @nicolas33. Is there a patch that I can use to verify the fix?

@khatchad
Copy link
Author

khatchad commented May 25, 2016

Thanks @dolohow. @nicolas33, I am still getting the same error:

OfflineIMAP 7.0.0-rc1
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
*** Processing account CityTech
Establishing connection to email1.citytech.cuny.edu:143
Syncing Cabinet: IMAP -> Maildir
Copy message 0 (1 of 6) Remote:Cabinet -> Local
Copy message 12500 (2 of 6) Remote:Cabinet -> Local
ERROR: Copying message 0 [acc: CityTech]
  UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: NFEE13 UID FETCH 0 (BODY.PEEK[])

Copy message 17271 (3 of 6) Remote:Cabinet -> Local
Thread 'Copy message from Remote:Cabinet' terminated with exception:
Traceback (most recent call last):
  File "/private/tmp/offlineimap/offlineimap/threadutil.py", line 172, in run
    Thread.run(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/private/tmp/offlineimap/offlineimap/folder/Base.py", line 797, in copymessageto
    message = self.getmessage(uid)
  File "/private/tmp/offlineimap/offlineimap/folder/IMAP.py", line 288, in getmessage
    data = self._fetch_from_imap(str(uid), 2)
  File "/private/tmp/offlineimap/offlineimap/folder/IMAP.py", line 698, in _fetch_from_imap
    res_type, data = imapobj.uid('fetch', uids, query)
  File "/private/tmp/offlineimap/offlineimap/imaplib2.py", line 1221, in uid
    return self._simple_command('UID', command, *args, **kw)
  File "/private/tmp/offlineimap/offlineimap/imaplib2.py", line 1691, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/private/tmp/offlineimap/offlineimap/imaplib2.py", line 1444, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))
error: UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: NFEE13 UID FETCH 0 (BODY.PEEK[])



Last 2 debug messages logged for Copy message from Remote:Cabinet prior to exception:
thread: Register new thread 'Copy message from Remote:Cabinet' (account 'CityTech')
imap:   08:12.92 Copy message from Remote:Cabinet last 20 log messages:
ERROR: Exceptions occurred during the run!
ERROR: Copying message 0 [acc: CityTech]
  UID command error: BAD ['UID FETCH Invalid parameter: 0']. Data: NFEE13 UID FETCH 0 (BODY.PEEK[])


Traceback:
  File "/private/tmp/offlineimap/offlineimap/folder/Base.py", line 797, in copymessageto
    message = self.getmessage(uid)
  File "/private/tmp/offlineimap/offlineimap/folder/IMAP.py", line 288, in getmessage
    data = self._fetch_from_imap(str(uid), 2)
  File "/private/tmp/offlineimap/offlineimap/folder/IMAP.py", line 698, in _fetch_from_imap
    res_type, data = imapobj.uid('fetch', uids, query)
  File "/private/tmp/offlineimap/offlineimap/imaplib2.py", line 1221, in uid
    return self._simple_command('UID', command, *args, **kw)
  File "/private/tmp/offlineimap/offlineimap/imaplib2.py", line 1691, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/private/tmp/offlineimap/offlineimap/imaplib2.py", line 1444, in _command_complete
    raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data))

@dolohow
Copy link
Member

dolohow commented May 25, 2016

Are you sure you are on branch next?

@khatchad
Copy link
Author

Yes.

$ git branch
  master
* next
$ git log -1
commit f00cbeed5acc5c40a21c378933e9ce1d8348bc83
Author: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Date:   Wed May 25 03:29:03 2016 +0200

    IMAP: ignore UID with 0 as value when searching for UIDs

    Some servers are broken: they return zero as valid UID and respond "BAD invalid
    parameter: 0" on the FETCH command.

    Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>

@nicolas33 nicolas33 reopened this May 25, 2016
@nicolas33
Copy link
Member

Weird. This UID zero is ignored at search time and it neither comes from the cache nor the Maildir. I wonder it is added by another IMAP command but I don't know which one right now.

Thanks for the test!

khatchad pushed a commit to khatchad/offlineimap that referenced this issue May 27, 2016
nicolas33 added a commit to nicolas33/offlineimap that referenced this issue Jun 27, 2016
Output a warning so that we can dig into this. For now, the patch doesn't fix
the root cause. If the server returns UID 0 as valid UID number, this must be
ignored as soon as possible.

Github-ref: OfflineIMAP#336
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
@nicolas33
Copy link
Member

Fixed in 65d4c94.

@khatchad
Copy link
Author

@nicolas33 Thank you! It works.

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

3 participants