botpress / v12

Botpress OSS – v12
https://v12.botpress.com
GNU Affero General Public License v3.0
68 stars 83 forks source link

[BUG] HITLNext new messages from an assigned / paused conversation from a channel-twilio user cause the platform to crash #1402

Closed RobertoE91 closed 2 years ago

RobertoE91 commented 2 years ago

Describe the bug Channel-Twilio uses bp.experimental.conversations.forBot to handle the conversationId wich expects to be of type uuid, in the other side, the hitl-next module relies in the channel-web to create a new conversation when the handoff is escalated and this conversation is being create with a conversatioId of type Int

Launcher Unhandled Rejection [Error, insert into `messages` (`authorId`, `conversationId`, `eventId`, `id`, `incomingEventId`, `payload`, `sentOn`) values (NULL, '14', '364954670003600037', '0dfb3930-8970-414b-9e89-b23d826724a3', NULL, '{"type":"typing","value":10}', '2021-07-27T20:48:12.893Z') - SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] STACK TRACE Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed Cluster [web] Restarting process...

as you can see, is trying to insert in the table "messages" a new typing event/message with 14 as the conversationId causing the entire platform to crash.

To Reproduce Steps to reproduce the behavior:

  1. Enable hitlnext module
  2. enable channel-twilio module
  3. Restart server
  4. Create a new empty bot
  5. configure channel-twilio
  6. Restart server
  7. Go to Flows and add the hitlnext/handoff action on the "on enter" section of the entry node
  8. Send new message from whatsapp
  9. Go to hitlnext module
  10. Go online
  11. Assign the conversation to you
  12. Once assigned send a new message from whatsapp
  13. See error

Expected behavior prevent the platform to crash and not compromise other bots

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context This issue also happends using postgresql

EFF commented 2 years ago

Thanks Roberto for reporting this , I'm pretty sure this is already being fixed by the extraction of messaging in a dedicated process.

@samuelmasse @laurentlp let's double check that.

samuelmasse commented 2 years ago

This should fix it on master botpress/botpress#5248