botpress / v12

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

Question marks being replaced with positional bindings in Postgres #1672

Closed jsgriffin closed 1 year ago

jsgriffin commented 2 years ago

Describe the bug

When a message contains a question mark, the question mark is replaced with a positional binding such as $1 when stored in the events database.

To Reproduce Steps to reproduce the behavior:

  1. Start a botpress instance using postgres as backing
  2. Post a message to any bot containing a question mark, such as Hello?
  3. Read the events from the database using e.g. psql
  4. See that the message was stored as Hello$1, as in below:
... | web     | ... | {"type":"text","channel":"web","direction":"outgoing","payload":{"type":"text","workflow":{},"text":"Hello$1","markdown":true,"typing":true},"target":"b84c3cdc-8797-453c-a0a9-ebacaa4e343c","botId":"boost-eq","createdOn":"2022-07-28T15:45:56.879Z","threadId":"d74ebeca-09cd-4ad6-a2ef-718dad525620","id":"28786047122291477","preview":"Hello$2","flags":{},"messageId":"a7c5db9e-0062-410f-b57a-66a19d85d371","incomingEventId":"28784735653166018","nlu":{"entities":[],"language":"n/a","ambiguous":false,"slots":{},"intent":{"name":"none","confidence":1,"context":"global"},"intents":[],"errored":false,"includedContexts":["global"],"ms":0}}

Expected behavior

The message should be stored as entered by the user (or as created by the bot)

Environment (please complete the following information):

Additional context

Note that this doesn't seem to be an issue when using sqlite - those events are stored correctly. I believe this may be an issue in event-collector.ts around line 160 and the use of knex.raw, but I'm not completely confident in that assessment. It's causing issues for us because we have a custom module which re-creates the conversation history for a user from the events table, and obviously this means we're showing incorrect messages back to the user.

davidvitora commented 1 year ago

If you want to check the message content, you can get it using the bp.messaging SDK