thunderbird / thunderbird/thunderbird-android
ClassCastException while retrieving mail from IMAP
Open
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 14k
- Forks
- 2.8k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 57
Description
Checklist
- I have used the search function to see if someone else has already submitted the same bug report.
- I will describe the problem with as much detail as possible.
App version
6.400
Where did you get the app from?
F-Droid
Android version
10
Device model
No response
Steps to reproduce
- 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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mail/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolder.kt at parseBodyStructure, especially the calls around line 861, and inspect ImapList.getString() in ImapList.java. Use the logged BODYSTRUCTURE response to reproduce the cast failure. Done means the affected IMAP message can be fetched without a ClassCastException and synchronization continues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100