Closed Bug 1679331 Opened 4 years ago Closed 4 years ago

messages.list(folder) throws unexpected error when a folder can't be found

Categories

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

defect

Tracking

(thunderbird_esr78+ fixed)

RESOLVED FIXED
85 Branch
Tracking Status
thunderbird_esr78 + fixed

People

(Reporter: arndissler, Assigned: arndissler)

References

Details

Attachments

(2 files, 2 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:84.0) Gecko/20100101 Firefox/84.0

Steps to reproduce:

Call Thunderbirds WebExtension API messages.list(folder) on a "dangling folder".

Actual results:

An exception will be thrown: folder is null.

Expected results:

The function call should return a default message object, e.g. { id: null, messages: [] }, so the extensions can handle this in a stable way.

Attached file Fixes the error in ext-messages (obsolete) —

I think list (or any of the functions that take a folder argument) should throw an exception in this case, just not this one.

So better throw an ExtensionError in this case than returning a default object?

Yes.

Looking at your first patch, the error message should refer to what the extension passed to the API (ie. folder.path) rather than a variable the API uses. That will make debugging the extension easier.

Assignee: nobody → email
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Summary: messages.list(folder) throws unexpected error → messages.list(folder) throws unexpected error when a folder can't be found

Updated according to the suggestion to throw an ExtensionError.

Attachment #9189775 - Attachment is obsolete: true

(In reply to Arnd Issler :arndissler from comment #0)

Call Thunderbirds WebExtension API messages.list(folder) on a "dangling folder".

Please note that Bug 1679333 seeks to remove support for "dangling folders".

See Also: → 1679333

The "dangling folders" can cause this issue, but it's not the only reason.

The WebExtension messages API is simply not handling all valid results from FolderLookupService, so I suggest to separate these two problems. There's also Bug 1529791, which seems to be an intersection of these two bugs (Bug 1679333 and this one here).

Comment on attachment 9189776 [details] [diff] [review]
bug-1679331--fix-messages-ext-list--extension-error.patch

You should ask for review if you want your patches to make any progress!

This is fine, but I would use !folder instead of folder === null as the test, and have the error message say what the error is. Something like "Folder not found: … etc.". The person most likely to be reading the error message is an extension developer like you, and I think you'd want the most helpful information you can get.

Attachment #9189776 - Flags: review+

Ah, didn't know that I have to request a review on this. Tanks for the hint.

I used folder === null, because the said Service explicitly returns null in this case, so checking the folders by using !folder it might filter more than expected and that's maybe cause some side effects on other parts of the codebase.

Adopted all the suggested changes to keep it according to the other extension files.

Attachment #9189776 - Attachment is obsolete: true
Attachment #9191726 - Flags: review+

...and the same patch for the current development line (former was for the ESR 78 branch)

Attachment #9191730 - Flags: review+
Target Milestone: --- → 85 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/d9755a67169a
messages.list(folder) throws unexpected error. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED

Comment on attachment 9191726 [details] [diff] [review]
bug-1679331--fix-messages-ext-list--esr78_20201207.patch

[Approval Request Comment]
Lets add-ons handle folder-not-found gracefully.

Attachment #9191726 - Flags: approval-comm-esr78?

Comment on attachment 9191726 [details] [diff] [review]
bug-1679331--fix-messages-ext-list--esr78_20201207.patch

[Triage Comment]
Approved for esr78

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

Attachment

General

Created:
Updated:
Size: