Fall back to LIST when XLIST advertises but returns unusable data - #63
Open
monperrus wants to merge 1 commit into
Open
Fall back to LIST when XLIST advertises but returns unusable data#63monperrus wants to merge 1 commit into
monperrus wants to merge 1 commit into
Conversation
Observed against a Dovecot (poste.io) deployment that advertises the
XLIST capability but replies to an XLIST command with just the tagged
completion status ("ok") instead of folder tuples — Mail::IMAPTalk's
generic command dispatch then hands folders() a single-element list
containing that string, and dereferencing $folder->[0] in the foreach
loop dies with "Can't use string ("ok") as an ARRAY ref".
Confirmed via direct testing: $imap->list('', '*') returns correctly
shaped data on the same connection where $imap->xlist('', '*') does
not, so this detects a malformed XLIST response and retries with the
standard LIST command instead of crashing account setup.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
JMAP::Sync::Common::folders()crashes with:on a live Dovecot (poste.io) deployment that advertises the
XLISTcapability in its
CAPABILITYresponse but, when actually sent anXLISTcommand, replies with just the tagged completion statusinstead of well-formed folder tuples.
folders()picks the list command based purely on capabilityadvertisement:
Reproduced directly against the live server with
Mail::IMAPTalk:Since
@foldersthen contains a single non-ref string'ok', theforeachloop's@{$folder->[0]}dereference dies with the errorabove, aborting account setup entirely (
POST /api/accountsreturns201with a"setup failed: ..."warning and the account neversyncs any folders/messages).
Fix
After calling the capability-selected command, detect a malformed
XLISTresult (any non-arrayref element) and retry with the standardLISTcommand, which is universally reliable. This only changesbehavior on the specific failure case — servers with working
XLISTare unaffected.
Testing
Verified end-to-end against the live deployment (poste.io mail server,
Dovecot backend) via the Docker image
(
ghcr.io/jmapio/jmap-proxy:latest):POST /api/accounts→201with"warning":"setup failed: Can't use string (\"ok\") as an ARRAY ref...",account left with 0 folders / 0 messages.
POST /api/accounts→ clean201, account synced6folders /49messages successfully.Also confirmed this is not a general "second IMAP command on the
connection" issue —
namespace()and plainlist()both workreliably on this server; only the generic
xlistdispatch returnsunusable data.