Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55450

JSON.stringify in Realm function does not encode correctly

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL
    • Hide

      What I did:

      Configure a Trigger function on a collection and log a property from a document:

      {{exports = async (changeEvent) => { }}{{console.log(JSON.stringify(changeEvent && changeEvent.fullDocument && changeEvent.fullDocument.name)) }}}

       Create a document with a curly brace in the `name` property, e.g. `{ "name": "Test’s" }`

      View the log entry for the create.

      What I expected:

      The log entry would show `Test’s`

      What actually happened:

      The log entry shows `Testâs`

      Additional notes:

      An example log entry is from our trigger named `fanx_data_legacy_dev` with the id `605a194e3684e76b32b532dd`.

      This is not limited to the `console.log` output: our trigger function pushes the JSON.stringify'd document to SQS, and the encoding shows the incorrect `Testâs` as well.

      Show
      What I did: Configure a Trigger function on a collection and log a property from a document: {{exports = async (changeEvent) => { }}{{console.log(JSON.stringify(changeEvent && changeEvent.fullDocument && changeEvent.fullDocument.name)) }}}  Create a document with a curly brace in the `name` property, e.g. `{ "name": "Test’s" }` View the log entry for the create. What I expected: The log entry would show `Test’s` What actually happened: The log entry shows `Testâs` Additional notes: An example log entry is from our trigger named `fanx_data_legacy_dev` with the id `605a194e3684e76b32b532dd`. This is not limited to the `console.log` output: our trigger function pushes the JSON.stringify'd document to SQS, and the encoding shows the incorrect `Testâs` as well.

      When I use JSON.stringify on an object containing the curly quote character, e.g. `’`, in a triggered function, it is encoded to `â`.

      This is affecting our very high visibility clients in the sport industry, e.g. the NCAA and others.

            Assignee:
            eric.sedor@mongodb.com Eric Sedor
            Reporter:
            developers@panda.industries Timmy Pandahouse
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: