Closed Bug 1778508 Opened 3 years ago Closed 3 years ago

API compose.sendMessage returns Promise with incomplete MessageHeader when email in Sent Folder is selected while sending

Categories

(Thunderbird :: Add-Ons: Extensions API, defect)

Thunderbird 102
defect

Tracking

(thunderbird_esr102? fixed, thunderbird103 fixed)

RESOLVED FIXED
104 Branch
Tracking Status
thunderbird_esr102 ? fixed
thunderbird103 --- fixed

People

(Reporter: florian.unger, Assigned: TbSync)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Steps to reproduce:

In an addon I compose a new mail (either a new mail or a reply to an existing mail) and then send the composed mail through the new API compose.sendMessage

Actual results:

When any mail in Sent folder is selected or
when the Sent folder in the folder pane of the main mail view alone is selected (without selecting a mail from the Sent folder)
while I compose and send a mail
then the returned Promise of the compose.sendMessage API call always has an incompletely filled messageheader object.

The returned Promise object looks like this:
{ "mode": "sendNow", "messages": [ { "id": 4, "date": "1970-01-01T00:00:00.000Z", "author": "", "recipients": [], "ccList": [], "bccList": [], "subject": "", "read": false, "headersOnly": false, "flagged": false, "junk": false, "junkScore": 0, "headerMessageId": "", "size": 0, "folder": { "accountId": "account3", "name": "Sent", "path": "/Sent", "type": "sent" }, "tags": [] } ], "headerMessageId": "92755f33-9606-aa32-60c7-5188ec56e3b5@dummy.com" }

Expected results:

the messages array should be correctly filled with the copies of the sent message.

I forgot to mention, the "headerMessageId" and "id" of the "messages" object are filled correctly.

But all other values like "date", "recipients", ... are wrong or empty.

Blocks: tb102found
Severity: -- → S3
Component: Untriaged → Add-Ons: Extensions API

This probably is related to a behavior I saw in Thunderbird 78 while I was developing the Experiment-API which was the inspiration for implementing API compose.sendMessage.

see https://thunderbird.topicbox.com/groups/addons/Tf1dcfa9c1f98109e-M07864d8188f9b6923cf12be7/retreive-a-sent-email

I recognized two strange behaviours/bugs while testing it (I used Thunderbird 78.8.1)

When 'Message Synchronizing' is deactivated for the Sent folder and I try to open the message with the messageId I got from the "onAfterSend" event using messenger.messages.getFull I get this exception:
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgMessageService.streamMessage]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource:///modules/gloda/MimeMessage.jsm :: MsgHdrToMimeMessage :: line 236" data: no] MimeMessage.jsm:236:16 MsgHdrToMimeMessage resource:///modules/gloda/MimeMessage.jsm:236 getFull chrome://messenger/content/parent/ext-messages.js:212 getFull chrome://messenger/content/parent/ext-messages.js:210 getFull self-hosted:844 result resource://gre/modules/ExtensionParent.jsm:996 withPendingBrowser resource://gre/modules/ExtensionParent.jsm:602 result resource://gre/modules/ExtensionParent.jsm:996 callAndLog resource://gre/modules/ExtensionParent.jsm:958 recvAPICall resource://gre/modules/ExtensionParent.jsm:995 AsyncFunctionNext self-hosted:693
The second and much stranger behaviour: When the Sent folder is selected in the folder pane of the main mail view while I compose and send a mail and then I try to get the messageheader for the messageId I got from the "onAfterSend" event using messenger.messages.get(messageId) then the returned messageheader is always null.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → john
Status: NEW → ASSIGNED

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/404155c0c03f
Convert msgHdr directly before it becomes invalid. r=#thunderbird-reviewers,mkmelin

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch

@ florian.unger : Can you verify, this is fixed in the latest Daily (2022-07-13)?

Flags: needinfo?(florian.unger)

Comment on attachment 9284942 [details]
Bug 1778508 - Convert msgHdr directly before it becomes invalid. r=#thunderbird-reviewers

[Approval Request Comment]
Regression caused by (bug #):
User impact if declined:
Add-ons sometimes return invalid messageHeaders

Testing completed (on c-c, etc.):
1 day on Daily, manual testing

Risk to taking this patch (and alternatives if risky):
Low. All I did was moving the conversion step to where we see the msgHdr, instead of storing the msgHdr object and converting it later.

Attachment #9284942 - Flags: approval-comm-beta?

Comment on attachment 9284942 [details]
Bug 1778508 - Convert msgHdr directly before it becomes invalid. r=#thunderbird-reviewers

[Triage Comment]
Approved for beta

Attachment #9284942 - Flags: approval-comm-beta? → approval-comm-beta+

I tested the Daily 104 from 2022-07-13 and it is fixed there. I was not able to reproduce the error anymore.
Many thanks for fixing this!

Will this get backported into the next ESR release?

Flags: needinfo?(florian.unger)

Comment on attachment 9284942 [details]
Bug 1778508 - Convert msgHdr directly before it becomes invalid. r=#thunderbird-reviewers

[Approval Request Comment]
Regression caused by (bug #):
User impact if declined:
Add-ons sometimes return invalid messageHeaders

Testing completed (on c-c, etc.):
1 day on Beta

Risk to taking this patch (and alternatives if risky):
Low. All I did was moving the conversion step to where we see the msgHdr, instead of storing the msgHdr object and converting it later.

Attachment #9284942 - Flags: approval-comm-esr102?

Patch applies cleanly to comm-esr102.

Comment on attachment 9284942 [details]
Bug 1778508 - Convert msgHdr directly before it becomes invalid. r=#thunderbird-reviewers

[Triage Comment]
approved for esr102

Attachment #9284942 - Flags: approval-comm-esr102? → approval-comm-esr102+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: