New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure body was successfully parsed as JSON before filtering #1065

Merged
merged 5 commits into from Nov 3, 2018

Conversation

Projects
None yet
1 participant
@50Wliu
Member

50Wliu commented Jul 2, 2018

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

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:

  • Manually invoke JSON.parse(), as before
  • Check for the status code
  • Use a combination of the above and a different library, such as window.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

50Wliu added some commits Sep 1, 2018

@50Wliu 50Wliu removed the work-in-progress label Nov 3, 2018

@50Wliu 50Wliu merged commit b7a8890 into master Nov 3, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@50Wliu 50Wliu deleted the wl-ensure-json branch Nov 3, 2018

@50Wliu 50Wliu referenced this pull request Nov 3, 2018

Merged

Update settings-view #18390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment