microsoft / BotFramework-Hubot

Hubot adapter for botframework
MIT License
111 stars 40 forks source link

Handling for undefined value of sourceEvent for message payload received from Skype for Business #18

Closed hcyjason closed 7 years ago

hcyjason commented 7 years ago

As the message payload format received from Skype for business is missing "sourceEvent", type error occurred to the middleware when reading property 'clientActivityId' in TextMiddleware.toReceivable function.

Attached the logs as below.

2017-09-12T16:41:04.255185294Z [Tue Sep 12 2017 16:41:04 GMT+0000 (UTC)] INFO hubot-botframework-adapter: onBotEvents
2017-09-12T16:41:04.255237694Z [Tue Sep 12 2017 16:41:04 GMT+0000 (UTC)] INFO hubot-botframework-adapter: Handling activity Channel: skypeforbusiness; type: message
2017-09-12T16:41:04.255245394Z [Tue Sep 12 2017 16:41:04 GMT+0000 (UTC)] INFO hubot-botframework-middleware: creating middleware...
2017-09-12T16:41:04.255252294Z [Tue Sep 12 2017 16:41:04 GMT+0000 (UTC)] INFO hubot-botframework-middleware: TextMiddleware toReceivable
2017-09-12T16:41:04.257131076Z TypeError: Cannot read property 'clientActivityId' of undefined
2017-09-12T16:41:04.257190876Z     at TextMiddleware.toReceivable (/var/www/chatbot-core/node_modules/hubot-botframework/src/middlewares.coffee:56:77)
2017-09-12T16:41:04.257201576Z     at BotFrameworkAdapter.handleActivity (/var/www/chatbot-core/node_modules/hubot-botframework/src/adapter.coffee:70:41)
2017-09-12T16:41:04.257208576Z     at BotFrameworkAdapter.onBotEvents (/var/www/chatbot-core/node_modules/hubot-botframework/src/adapter.coffee:66:10)
2017-09-12T16:41:04.257215076Z     at ChatConnector.onEventHandler (/var/www/chatbot-core/node_modules/hubot-botframework/src/adapter.coffee:57:45)
2017-09-12T16:41:04.257221276Z     at ChatConnector.onDispatchEvents (/var/www/chatbot-core/node_modules/botbuilder/lib/bots/ChatConnector.js:426:22)
2017-09-12T16:41:04.257276975Z     at ChatConnector.dispatch (/var/www/chatbot-core/node_modules/botbuilder/lib/bots/ChatConnector.js:435:18)
2017-09-12T16:41:04.257286375Z     at /var/www/chatbot-core/node_modules/botbuilder/lib/bots/ChatConnector.js:141:27
2017-09-12T16:41:04.257292575Z     at OpenIdMetadata.getKey (/var/www/chatbot-core/node_modules/botbuilder/lib/bots/OpenIdMetadata.js:26:13)
2017-09-12T16:41:04.257298975Z     at ChatConnector.verifyBotFramework (/var/www/chatbot-core/node_modules/botbuilder/lib/bots/ChatConnector.js:116:28)
2017-09-12T16:41:04.257305275Z     at /var/www/chatbot-core/node_modules/botbuilder/lib/bots/ChatConnector.js:44:23
2017-09-12T16:41:04.257311775Z     at callbacks (/var/www/chatbot-core/node_modules/hubot/node_modules/express/lib/router/index.js:164:37)
2017-09-12T16:41:04.257317975Z     at param (/var/www/chatbot-core/node_modules/hubot/node_modules/express/lib/router/index.js:138:11)
2017-09-12T16:41:04.257324275Z     at pass (/var/www/chatbot-core/node_modules/hubot/node_modules/express/lib/router/index.js:145:5)
2017-09-12T16:41:04.257330575Z     at Router._dispatch (/var/www/chatbot-core/node_modules/hubot/node_modules/express/lib/router/index.js:173:5)
2017-09-12T16:41:04.257365774Z     at Object.router (/var/www/chatbot-core/node_modules/hubot/node_modules/express/lib/router/index.js:33:10)
2017-09-12T16:41:04.257373174Z     at next (/var/www/chatbot-core/node_modules/connect/lib/proto.js:174:15)
2017-09-12T16:41:04.257379174Z     at Object.multipart [as handle] (/var/www/chatbot-core/node_modules/connect-multiparty/index.js:42:27)
2017-09-12T16:41:04.257385774Z     at next (/var/www/chatbot-core/node_modules/connect/lib/proto.js:174:15)
2017-09-12T16:41:04.257394674Z     at Object.urlencodedParser [as handle] (/var/www/chatbot-core/node_modules/body-parser/lib/types/urlencoded.js:81:44)
2017-09-12T16:41:04.257401074Z     at next (/var/www/chatbot-core/node_modules/connect/lib/proto.js:174:15)
2017-09-12T16:41:04.257407074Z     at /var/www/chatbot-core/node_modules/body-parser/lib/read.js:121:5
2017-09-12T16:41:04.257413274Z     at invokeCallback (/var/www/chatbot-core/node_modules/raw-body/index.js:262:16)
2017-09-12T16:41:04.257447374Z     at done (/var/www/chatbot-core/node_modules/raw-body/index.js:251:7)
2017-09-12T16:41:04.257456473Z     at IncomingMessage.onEnd (/var/www/chatbot-core/node_modules/raw-body/index.js:307:7)
2017-09-12T16:41:04.257462573Z     at emitNone (events.js:86:13)
2017-09-12T16:41:04.257468473Z     at IncomingMessage.emit (events.js:185:7)
2017-09-12T16:41:04.257474273Z     at endReadableNT (_stream_readable.js:974:12)
2017-09-12T16:41:04.257480173Z     at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-09-12T16:41:04.257486073Z     at process._tickCallback (internal/process/next_tick.js:104:9)
MatSFT commented 7 years ago

Here is a Pr to fix your issue and add tests around it: https://github.com/Microsoft/BotFramework-Hubot/pull/19

maxpert commented 7 years ago

Resolve in v0.10.1