Gmail IMAP sometimes returns bad retrieval results

I am using python to connect to gmail via IMAP.

When I sample for a bunch of uids, the results sometimes contain a couple of weird ones attached to the end.

This error appears intermittently and starts showing up sometime in the last week or so.

For example, I am sampling like:

>>>import imaplib
>>>conn = imaplib.IMAP4_SSL('imap.gmail.com')
>>># authenticate etc
>>>conn.uid('fetch', '12,13', '(X-GM-THRID)')

      

I sometimes get a result like:

>>>['1 (X-GM-THRID 123123123123 UID 12)', 
    '2 (X-GM-THRID 123123123123 UID 13)', 
    '365022 (UID 601722 FLAGS (\\Seen))']

      

(Line breaks added for reading, ids changed from original, I usually get a lot more than two.)

This is pretty weird. I didn't ask for anything for an additional message. Sometimes it's there, sometimes it's not. No matter what fields I get, the additional result (I've only seen one or two) never contains them and only contains FLAGS information.

Any ideas why this might be happening?

+3


source to share


2 answers


Earlier this week, the following was posted on the IMAP mailing list:

"As of yesterday [Monday, Oct 7] Gmail now supports changing report flags anywhere we report new / deleted messages (that is, most locations are allowed by protocol, but definitely during IDLE). It's only available for gmail.com users at the moment, Google Apps users will follow in a week or so if we don't find any problems. "

However, there seem to be problems with the new functionality because today they said they were rolling back:



"We are seeing a few reports about programs that were not expecting additional FETCH responses that we posted on Monday. We are rolling back soon as older versions of a very popular client are having problems (although we do not know this part of things).

-Rick

+3


source


Gmail sends you unsolicited updates FLAGS

(because someone deleted the message remotely). This is not in response to your request, but IMAP allows the server to send you any * information at any time. Many servers will keep these unsolicited responses for replies IDLE

or NOOP

, but apparently Gmail doesn't want to wait.

However, until recently (apparently?) Gmail did not send flags updates at all, only EXPUNGE.



*: There are several rules by which responses can be sent when race conditions should be avoided, but this is not one of them.

+2


source







All Articles