thunderbird / thunderbird-android

Thunderbird for Android – Open Source Email App for Android (fka K-9 Mail)
https://thunderbird.net/mobile
Apache License 2.0
10.95k stars 2.51k forks source link

ClassCastException while retrieving mail from IMAP #6800

Open agalanin opened 1 year ago

agalanin commented 1 year ago

Checklist

App version

6.400

Where did you get the app from?

F-Droid

Android version

10

Device model

No response

Steps to reproduce

  1. Try to fetch new messages from IMAP server

Expected behavior

Message fetched OK

Actual behavior

java.lang.ClassCastException: com.fsck.k9.mail.store.imap.ImapList cannot be cast to java.lang.String

Fetching messages stops at this position without any error message.

Still reproduces in version 6.510.

Logs

04-02 00:22:02.035 17431 17452 V RealImapConnection: conn164086162>>> 28 UID FETCH 19619,19618,19617,19616 (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc reply-to message-id references in-reply-to list-unsubscribe X-K9mail-Identity Chat-Version)])
04-02 00:22:02.095 17431 17452 V RealImapConnection: conn164086162<<<#null# [5327, FETCH, [UID, 19616, FLAGS, [\Seen, encrypted, system_hamon], INTERNALDATE, 29-Mar-2023 18:44:42 +0000, RFC822.SIZE, 84581, BODY, [HEADER.FIELDS, [Chat-Version, list-unsubscribe, in-reply-to, references, message-id, reply-to, content-type, X-K9mail-Identity, subject, cc, to, from, date]], Date: Wed, 29 Mar 2023 21:44:07 +0300 (MSK)
04-02 00:22:02.095 17431 17452 V RealImapConnection: From: addr1@example1.org
04-02 00:22:02.095 17431 17452 V RealImapConnection: To: addr2@example2.ru
04-02 00:22:02.095 17431 17452 V RealImapConnection: Message-ID: <141234567.2591681234567890.JavaMail.tech_user@rmcp-monolith-6c6bcfffff-7ffff>
04-02 00:22:02.095 17431 17452 V RealImapConnection: Subject: subject
04-02 00:22:02.095 17431 17452 V RealImapConnection: Content-Type: multipart/mixed; 
04-02 00:22:02.095 17431 17452 V RealImapConnection:    boundary="----=_Part_364_1114187583.1680115447937"
04-02 00:22:02.095 17431 17452 V RealImapConnection: 
04-02 00:22:02.095 17431 17452 V RealImapConnection: ]]
...
04-02 00:22:02.137 17431 17452 D ImapSync: SYNC: Synced unsynced messages for folder INBOX
04-02 00:22:02.138 17431 17452 D ImapSync: SYNC: Have 4 large messages and 0 small messages out of 4 unsynced messages
04-02 00:22:02.138 17431 17452 D ImapSync: SYNC: Fetching 0 small messages for folder INBOX
04-02 00:22:02.138 17431 17452 D ImapSync: SYNC: Done fetching small messages for folder INBOX
04-02 00:22:02.139 17431 17452 D ImapSync: SYNC: Fetching large messages for folder INBOX
04-02 00:22:02.141 17431 17452 V RealImapConnection: conn164086162>>> 29 UID FETCH 19616,19617,19618,19619 (UID BODYSTRUCTURE)
04-02 00:22:02.197 17431 17452 V RealImapConnection: conn164086162<<<#null# [5327, FETCH, [UID, 19616, BODYSTRUCTURE, [[related, [boundary, ----=_Part_365_528345150.1680115447937], NIL, NIL, NIL], [application, pdf, [name, account_details_*5222.pdf], NIL, NIL, base64, 81284, NIL, [attachment, [filename, account_details_*5222.pdf]], NIL, NIL], mixed, [boundary, ----=_Part_364_1114187583.1680115447937], NIL, NIL, NIL]]]
04-02 00:22:02.198 17431 17452 E ImapSync: synchronizeMailbox
04-02 00:22:02.198 17431 17452 E ImapSync: java.lang.ClassCastException: com.fsck.k9.mail.store.imap.ImapList cannot be cast to java.lang.String
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.mail.store.imap.ImapList.getString(ImapList.java:38)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.mail.store.imap.RealImapFolder.parseBodyStructure(RealImapFolder.kt:861)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.mail.store.imap.RealImapFolder.parseBodyStructure(RealImapFolder.kt:828)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.mail.store.imap.RealImapFolder.handleFetchResponse(RealImapFolder.kt:746)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.mail.store.imap.RealImapFolder.fetch(RealImapFolder.kt:597)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.backend.imap.ImapSync.downloadLargeMessages(ImapSync.kt:561)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.backend.imap.ImapSync.downloadMessages(ImapSync.kt:367)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.backend.imap.ImapSync.synchronizeMailboxSynchronous(ImapSync.kt:198)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.backend.imap.ImapSync.sync(ImapSync.kt:34)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.backend.imap.ImapBackend.sync(ImapBackend.kt:55)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController.syncFolder(MessagingController.java:616)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController.synchronizeMailboxSynchronous(MessagingController.java:556)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController.lambda$synchronizeMailbox$3(MessagingController.java:528)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController.$r8$lambda$ar_6eNiqt1c67rfo1nCyGoIX3Sg(Unknown Source:0)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController$$ExternalSyntheticLambda20.run(Unknown Source:10)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController.runInBackground(MessagingController.java:222)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController.access$000(MessagingController.java:108)
04-02 00:22:02.198 17431 17452 E ImapSync:  at com.fsck.k9.controller.MessagingController$1.run(MessagingController.java:163)
04-02 00:22:02.198 17431 17452 E ImapSync:  at java.lang.Thread.run(Thread.java:919)
cketti commented 1 year ago

It looks like the server is sending an invalid FETCH response. What server are you connecting to? Do you know what server software your email provider is using?

agalanin commented 1 year ago

@cketti, I'm connecting to imap.yandex.ru. Unfortunately I don't know what IMAP server software running on this server. Probably it's something proprietary.

cketti commented 1 year ago

Can you provide the full MIME structure of the message causing this error?

agalanin commented 1 year ago

I replaced file content with (base-64 encoded file) but preserved MIME structure

Date: Wed, 12 Mar 2023 03:45:06 +0300 (MSK)
From: addr1@example1.org
To: addr2@example2.ru
Message-ID: <141234567.2591681234567890.JavaMail.tech_user@rmcp-monolith-6c6bcfffff-7ffff>
Subject: subject
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_364_1114187583.1680115447937"

------=_Part_364_1114187583.1680115447937
Content-Type: multipart/related; 
    boundary="----=_Part_365_528345150.1680115447937"

------=_Part_365_528345150.1680115447937--

------=_Part_364_1114187583.1680115447937
Content-Type: application/pdf; name=account_details_*1234.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=account_details_*1234.pdf

(base-64 encoded file)
------=_Part_364_1114187583.1680115447937--
mhf1998 commented 1 year ago

Hello Alexander,

I have been trying to reproduce the issue you described (in Samsung A6, Android10, With a Gmail account ), but I am having difficulty doing so. I was wondering if you could provide me with more information on the scenario you experienced in order to help us resolve the issue.

Specifically, could you please provide me with more details on how to reproduce the issue, as well as any other information that could be helpful in diagnosing and fixing the bug?

Your assistance in this matter would be greatly appreciated. Thank you for your time and help in resolving this issue.

Best regards, Husain

mhf1998 commented 1 year ago

could you attach a picture or video for this scenario?

agalanin commented 1 year ago

There is nothing that I can record on a video or show on an image. All messages starting from problematic one are not displayed in UI without any visible errors.

Probably the issue is related to my mail server (https://mail.yandex.ru) since it can't be reproduced with GMail. You may register an account for free.

mhf1998 commented 1 year ago

There is nothing that I can record on a video or show on an image. All messages starting from problematic one are not displayed in UI without any visible errors.

Probably the issue is related to my mail server (https://mail.yandex.ru) since it can't be reproduced with GMail. You may register an account for free.

Thanks Alexander.