Skip to content

Make the malformed response error message debuggable #4177

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

Merged
merged 3 commits into from
Sep 20, 2017

Conversation

TylerBrock
Copy link
Contributor

It would be nice if this error message contained some or all of the malformed response to aid in debugging the problem. What do you think?

@codecov
Copy link

codecov bot commented Sep 18, 2017

Codecov Report

Merging #4177 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4177   +/-   ##
=======================================
  Coverage   92.21%   92.21%           
=======================================
  Files         116      116           
  Lines        8089     8089           
=======================================
  Hits         7459     7459           
  Misses        630      630
Impacted Files Coverage Δ
src/Controllers/HooksController.js 96.33% <0%> (ø) ⬆️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.5% <0%> (-0.12%) ⬇️
src/RestWrite.js 93.34% <0%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9371958...55ada64. Read the comment docs.

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -191,7 +191,11 @@ function wrapToHTTPRequest(hook, key) {
try {
body = JSON.parse(body);
} catch (e) {
err = { error: "Malformed response", code: -1 };
err = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the e: SyntaxError have any useful info?

think this is worth unit testing??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case i'm trying to cover here isn't actually bad JSON it's when you don't have JSON at all and the text reads "Socket closed because not https" or something like that. We could also provide the e.toString() or e.message though for when there is a problem with the json formatting (but I think that is much less common since these are usually machine serialized results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely useful but feels sloppy, any other ideas on how to make this better @acinader?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't over think it. adds good feedback on an error. I approved it cause I think it's mergeable.

@TylerBrock TylerBrock merged commit 70ca7bd into parse-community:master Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants