This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Make sure body was successfully parsed as JSON before filtering #1065
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Description of the Change
In #1014, package searches were changed to use the atom.io API endpoint rather than calling out through apm. As part of that change, parsing of the resulting JSON data was delegated to the
request
module. Interestingly,request
does not throw an error when it fails to parse the response body as JSON and instead returns the raw body as a string. The new package search code failed to account for this scenario, which resulted in #1052.Alternate Designs
There are a couple of alternate designs:
JSON.parse()
, as beforewindow.fetch()
I haven't decided which one to go with yet.
Benefits
Searching should be more resilient to server errors.
Possible Drawbacks
None.
Applicable Issues
Fixes #1052