Skip to content
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

Check if "body" on "response" is actually defined before accessing it #477

Merged
merged 1 commit into from
Dec 21, 2017
Merged

Check if "body" on "response" is actually defined before accessing it #477

merged 1 commit into from
Dec 21, 2017

Conversation

phgroe
Copy link
Contributor

@phgroe phgroe commented Oct 11, 2017

Catched this error when testing with a dummy API key.

TypeError: Cannot read property 'errors' of undefined
    at ResponseError.toString (.../node_modules/@sendgrid/helpers/classes/response-error.js:45:27)
    at parseStackAndMessage (.../node_modules/bluebird/js/release/debuggability.js:574:25)
    at CapturedTrace.attachExtraTrace (.../node_modules/bluebird/js/release/debuggability.js:778:18)

After adding the simple check if (body && Array.isArray(body.errors)) the "Unauthorized (401)" error is properly returned as promise rejection.

Catched this error when testing with a dummy API key.
```
TypeError: Cannot read property 'errors' of undefined
    at ResponseError.toString (.../node_modules/@sendgrid/helpers/classes/response-error.js:45:27)
    at parseStackAndMessage (.../node_modules/bluebird/js/release/debuggability.js:574:25)
    at CapturedTrace.attachExtraTrace (.../node_modules/bluebird/js/release/debuggability.js:778:18)
```
After adding the simple check `if (body && Array.isArray(body.errors))` the "Unauthorized (401)" error is properly returned as promise rejection.
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 11, 2017
@SendGridDX
Copy link
Collaborator

SendGridDX commented Oct 11, 2017

CLA assistant check
All committers have signed the CLA.

@thinkingserious thinkingserious added difficulty: medium fix is medium in difficulty hacktoberfest status: code review request requesting a community code review or review from Twilio labels Oct 11, 2017
@thinkingserious
Copy link
Contributor

@phgroe

We have not been able to merge your Pull Request, but because you are awesome - we wanted to make sure you could still get a SendGrid Hacktoberfest shirt.

Please go fill out our swag form before Nov 5th and we will send the shirt! (We know that you might have tried this before and it didn’t work, sorry about that!)

You have till Nov 5th to fill out this form in order to get the Hacktoberfest shirt!

Thank you for contributing during Hacktoberfest! We hope to see you in the repos soon! Just so you know, we always give away a SendGrid shirt for your first ever non-Hacktoberfest PR that gets merged.

@phgroe
Copy link
Contributor Author

phgroe commented Nov 3, 2017

Thanks for the offer, but I already have way too many t-shirts! I'd be more interested in seeing this fix merged, the bug produces a TypeError that will crash an application when using an invalid API key.

Why have you not been able to merge the PR? If it is because of the mass of contributions to Hacktoberfest, then right you are. If there are other reasons, let me know.

@thinkingserious
Copy link
Contributor

Hi @phgroe,

I appreciate that you many have too many T-shirts, but you don't have the totally awesome special edition SendGrid Hacktoberfest T-shirt, plus the sticker and exclusive pin :)

You are correct, we have not merged the PR because we are way behind with over 1,000 PRs submitted to us in October. We are going from oldest to newest to be as fair as we can. You can help out, if you have time, by reviewing outstanding PRs, as it's easier for us to merge a PR when it's already been reviewed by someone else.

Thank again for your support and patience.

With Best Regards,

Elmer

@thinkingserious thinkingserious merged commit 069bd43 into sendgrid:master Dec 21, 2017
@thinkingserious
Copy link
Contributor

Hello @phgroe,

Thanks again for the PR!

We appreciate your contribution and look forward to continued collaboration. Thanks!

Team SendGrid DX

@phgroe phgroe deleted the fix/response-body-check-undefined branch December 22, 2017 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants