Closed Bug 1634323 Opened 4 years ago Closed 2 years ago

Undocumented potential errors in download() method of AttachmentDownloader / Downloader

Categories

(Firefox :: Remote Settings Client, task)

task

Tracking

()

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: robwu, Assigned: leplatrem)

Details

Attachments

(1 file)

The download and downloadAsBytes methods of the Downloader / AttachmentDownloader in the RemoteSettings client have two documented errors:

   * @throws {Downloader.DownloadError} if the file could not be fetched.
   * @throws {Downloader.BadContentError} if the downloaded file integrity is not valid.

But those are not the only ones. There is one obvious one, NetworkError, which could happen when fetch() is unable to connect to the server, with call stack:

There is another error, "SyntaxError: JSON.parse ...", which could happen if the received response is incomplete or invalid JSON, with call stack:

When this second error happens, there is a very obscure error with no indication of the source, as seen in a xpcshell test failure in https://bugzilla.mozilla.org/show_bug.cgi?id=1620621#c10 (which I could not reproduce locally, but by changing the services.settings.server value to data:,... I was able to reproduce it):

Unexpected exception SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data at /Users/cltbld/tasks/task_1588226248/build/tests/xpcshell/head.js:242
_do_main@/Users/cltbld/tasks/task_1588226248/build/tests/xpcshell/head.js:242:6
_execute_test@/Users/cltbld/tasks/task_1588226248/build/tests/xpcshell/head.js:569:5
@-e:1:1

I think that there should be some more explicit handling of errors in _baseAttachmentsURL. Callers should not be able to observe obscure JSON parsing errors.

Assignee: nobody → mathieu
Attachment #9269393 - Attachment description: WIP: Bug 1634323 - Document and catch server error on attachment download → Bug 1634323 - Document and catch server error on attachment download r?gbeckley
Status: NEW → ASSIGNED
Pushed by mleplatre@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a531028fae48
Document and catch server error on attachment download r=gbeckley
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: