command CHECK illegal in state AUTH

Sebastian Spaeth Sebastian at
Mon Sep 26 15:15:58 BST 2011

On Sat, 24 Sep 2011 00:25:13 -0400, Dave Abrahams <dave at> wrote:
> offlineimap/folder/", line 561, in savemessage
>     (typ,dat) = imapobj.check()
> error: command CHECK illegal in state AUTH
>   command CHECK illegal in state AUTH

Now, that is a fun one. And embarrassing... I actually got the dropped
connection retry loop wrong, and here is a small and innocent fix for

Commit: e145beb
Date:   Mon Sep 26 16:04:00 2011 +0200

Fix "command CHECK illegal in state AUTH"

Dave identified a case where our new dropped connection handling did
not work out correctly: we use the retry_left variable to signify
success (0=success if no exception occured).

However, we were decrementing the variable AFTER all the exception
checks, so if there was an exception due to dropped connections, it
could well be that we 1) did not raise an exception (because we want to
retry), and 2) then DECREMENTED retry_left, which was indicated "all is
fine, no need to retry".

The code then continued to check() the append, which failed with the
above message (because we obtained a new connection which had not even
selected the current folder and we were still in mode AUTH). The fix is
of course, to fix our logic: Decrement retry_left first, THEN decide
whether to raise() (retry_left==0) or retry (retry_left>0) which would
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <>

More information about the OfflineIMAP-project mailing list