Gmail to "gmail apps" sync: ValueError: Backend could not find uid for message
Sebastian at sspaeth.de
Wed Mar 23 15:55:54 GMT 2011
Alexander has sent me the log files and I analyzed them (the 'backend
could not assign uid' problem). I am a bit puzzled and at the moment, I
blame it entirely on the gmail imap implementation:
Alexander has 2 problems:
1) His gmail server is not advertising the UIDPLUS extension all the
time which directly allows to get the UID of an APPENDed message. His
gmail imap capabilities reply looked like this:
'IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA XLIST CHILDREN XYZZY SASL-IR AUTH=XOAUTH'
while mine look like this:
'IMAP4REV1', 'UIDPLUS', 'CHILDREN', 'NAMESPACE',
'THREAD=ORDEREDSUBJECT', 'THREAD=REFERENCES', 'SORT', 'QUOTA', 'IDLE',
both are from imap.gmail.com, so their servers seem very different under
whatever mysterious conditions.
Without UIDPLUS, we munge our mail header to insert a custom header
like this: X-OfflineIMAP: 3132605382-7478425151
and APPEND the message.
(despite not announcing UIDPLUS, gmail DOES return the new UID ('APPENDUID
648448589') which we could have used in the first place, so that is
definitely a gmail bug on their side.)
We then try to search gmail for the newly appended message:
UID SEARCH HEADER X-OfflineIMAP "3132605382-7478425151"
which leads to "OK SEARCH completed (Success)" returning an empty set of
The message we just uploaded was not found, although it must be there
(we just uploaded it), so we fail to identify the new UID. Which leads
to the exception as we cannot return the UID of the message in question.
So 2 things going on: 1) Gmail fails to advertize UIDPLUS (in some cases)
although they definitely support it, which is bad.
2) Gmail fails to find the message header in a message we have just
uploaded. This is doubly bad on the gmail side.
I know that gmail is popular and often unavoidable. But it is not proper
IMAP :-(. The one workaround that we could do is to hardcode UIDPLUS
support in the gmail case, since we know that gmail supports it (but who
knows if they really support it in all cases?). I would be rather
hesitant to do that hard coding.
I suggest someone files a bug report with them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: not available
More information about the OfflineIMAP-project