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

user is undefined when name is not a current user #332

Merged
merged 1 commit into from Apr 12, 2017

Conversation

frejos
Copy link
Contributor

@frejos frejos commented Apr 8, 2017

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've been mindful about doing atomic commits, adding documentation to my changes, not refactoring too much.
  • I've a descriptive title and added any useful information for the reviewer. Where appropriate, I've attached a screenshot and/or screencast (gif preferrably).
  • [N/A] I've written tests to cover the new code and functionality included in this PR.
  • I've read, agree to, and signed the Contributor License Agreement (CLA).

PR Summary

Calling SlackMemoryDataStore.prototype.getDMByName with a name that is not a current user should return undefined, but currently throws a TypeError.

return find(this.dms, ['user', user.id]);
^
TypeError: Cannot read property 'id' of undefined

Simple fix to check for existence or user prior to doing search and appropriately returning undefined if it does not.

Related Issues

Did not open issue.

Test strategy

No additional or changed functionality, searching for name that is not a current user.

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2017

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Apr 8, 2017

Codecov Report

Merging #332 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #332   +/-   ##
=======================================
  Coverage   85.72%   85.72%           
=======================================
  Files          44       44           
  Lines        1198     1198           
  Branches      175      176    +1     
=======================================
  Hits         1027     1027           
  Misses        171      171
Impacted Files Coverage Δ
lib/data-store/memory-data-store.js 80.35% <100%> (ø) ⬆️

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 c6d711d...993e5a3. Read the comment docs.

@aoberoi aoberoi merged commit 652e68b into slackapi:master Apr 12, 2017
@aoberoi
Copy link
Contributor

aoberoi commented Apr 12, 2017

good catch, thanks @frejos!

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.

None yet

3 participants