Hubot-slack: TypeError: Cannot read property 'toString' of undefined

Created on 11 Jan 2017  ยท  9Comments  ยท  Source: slackapi/hubot-slack

  • [ X ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [ X ] I've read and agree to the Code of Conduct.
  • [ X ] I've searched for any related issues and avoided creating a duplicate issue.

Description

Hubot crashes with the error message: TypeError: Cannot read property 'toString' of undefined
The error is not in the adapters source code, but I believe the error is related to issue #388

TypeError: Cannot read property 'toString' of undefined
at new User (/usr/src/bot/node_modules/hubot/src/user.coffee:9:19, :14:46)
at Brain.userForId (/usr/src/bot/node_modules/hubot/src/brain.coffee:106:7, :93:16)
at SlackBot.userChange (/usr/src/bot/node_modules/hubot-slack/src/bot.coffee:233:5, :307:31)
at RTMClient. (/usr/src/bot/node_modules/hubot-slack/src/bot.coffee:1:1, :3:61)
at RTMClient.emit (/usr/src/bot/node_modules/eventemitter3/index.js:116:35)
at RTMClient.emit (/usr/src/bot/node_modules/@slack/client/lib/clients/client.js:79:39)
at RTMClient._handleWsMessageViaEventHandler (/usr/src/bot/node_modules/@slack/client/lib/clients/rtm/client.js:465:10)
at RTMClient.handleWsMessage (/usr/src/bot/node_modules/@slack/client/lib/clients/rtm/client.js:419:10)
at WebSocket.wrapper (/usr/src/bot/node_modules/@slack/client/node_modules/lodash/lodash.js:4968:19)
at emitTwo (events.js:87:13)
at WebSocket.emit (events.js:172:7)
at Receiver.ontext (/usr/src/bot/node_modules/ws/lib/WebSocket.js:841:10)
at /usr/src/bot/node_modules/ws/lib/Receiver.js:536:18
at Receiver.applyExtensions (/usr/src/bot/node_modules/ws/lib/Receiver.js:371:5)
at /usr/src/bot/node_modules/ws/lib/Receiver.js:508:14
at Receiver.flush (/usr/src/bot/node_modules/ws/lib/Receiver.js:347:3)
at Receiver.opcodes.1.finish (/usr/src/bot/node_modules/ws/lib/Receiver.js:541:12)
at Receiver.expectHandler (/usr/src/bot/node_modules/ws/lib/Receiver.js:499:31)
at Receiver.add (/usr/src/bot/node_modules/ws/lib/Receiver.js:103:24)
at TLSSocket.realHandler (/usr/src/bot/node_modules/ws/lib/WebSocket.js:825:20)
at emitOne (events.js:77:13)
at TLSSocket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at TLSSocket.Readable.push (_stream_readable.js:110:10)
at TLSWrap.onread (net.js:523:20)

Reproducible in:

{project_name} version:
OS version(s): Ubuntu
Device(s):

Steps to reproduce:

N/A

Expected result:

N/A

Actual result:

N/A

Attachments:

N/A

Most helpful comment

I just wanted folks to know that we've seen a number of issues stemming from this in the wild, so I've raised the priority level. I plan to address this with either the generously contributed PR from @pearswj or something myself and make a release next week.

All 9 comments

I've also noticed this error recently. It looks like it's cropping up in the user_change event handler. Looks to be related to #381. Easily reproducible by editing my Slack profile.

Hubot-slack v4.3.1 running on Heroku.

Adding a console.log userproves what the docs say. The user object is inside the "user_change" object.

{ type: 'user_change',
  user: 
    { id: 'U0123ABCD',
      team_id: 'T0123ABCD',
      name: 'will',
      ... },
   ... }

This issue is also repro in MacOs ElCapitan 10.11.6

โ”œโ”€โ”ฌ [email protected]
โ”‚ โ”œโ”€โ”ฌ @slack/[email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ UNMET DEPENDENCY slack@^8.1.2
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”ฌ [email protected]
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ [email protected]
โ”‚ โ”‚ โ””โ”€โ”ฌ [email protected]
โ”‚ โ”‚   โ”œโ”€โ”€ [email protected]
โ”‚ โ”‚   โ””โ”€โ”€ [email protected]
โ”‚ โ””โ”€โ”€ [email protected]

I just wanted folks to know that we've seen a number of issues stemming from this in the wild, so I've raised the priority level. I plan to address this with either the generously contributed PR from @pearswj or something myself and make a release next week.

hi folks! ive got a fix for this issue in #399. @pearswj thanks for your contribution, but IMHO the changes you made were a little larger than necessary to fix the issue and we prefer a smaller change, so i'll be closing that after i merge this.

@aoberoi No worries. Thanks for the feedback.

Is there a workaround for this by chance?

@zero1zero The fix (see #399) was _just_ released in v4.3.2 ๐Ÿ™‚

Thanks for the fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tigris picture tigris  ยท  4Comments

resteinbock picture resteinbock  ยท  9Comments

gabriel403 picture gabriel403  ยท  10Comments

magander3 picture magander3  ยท  8Comments

EasyAsABC123 picture EasyAsABC123  ยท  13Comments