Undocumented potential errors in download() method of AttachmentDownloader / Downloader
Categories
(Firefox :: Remote Settings Client, task)
Tracking
()
| 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:
_fetchAttachmentdownloadAsBytesdownload- (
NetworkErroris explicitly handled in theAttachmentDownloadersubclass though)
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 | ||
Comment 1•3 years ago
|
||
Updated•3 years ago
|
Comment 3•3 years ago
|
||
| bugherder | ||
Description
•