Closed Bug 881717 Opened 8 years ago Closed 8 years ago

Deal with err case in MakeAPI callback

Categories

(Webmaker Graveyard :: webmaker.org, defect)

x86
macOS
defect
Not set
blocker

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: humph, Assigned: mjschranz)

Details

Attachments

(1 file)

We have code in webmaker.org that is using the MakeAPI, but assuming that no error is returned.  This results in us trying to access a .length property of a null object (data), which in turn crashes the server.

The problem is in https://github.com/mozilla/webmaker.org/blob/master/lib/makeapi-webmaker.js#L7

We should be doing 2 things there.

1) check on what the value of err is, and if non-null, deal with it here (i.e., early callback vs. processing data).

2) check that data is non-null before we try to access any properties on it.  It *should* be an array; but if it isn't, let's not crash.
Attachment #760920 - Flags: review?(david.humphrey)
Comment on attachment 760920 [details] [review]
https://github.com/mozilla/webmaker.org/pull/106

One switch to the data-null case, looks good with that.

Thanks for patching so quickly.  Let's get this landed.
Attachment #760920 - Flags: review?(david.humphrey) → review+
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Attachment mime type: text/plain → text/x-github-pull-request
You need to log in before you can comment on or make changes to this bug.