Inside an Atlas Triggered function, when I use JSON.stringify or console.log a property containing the curly quote character, e.g. ’, the output is changed to â.
What I did
Configure a Trigger function on a collection and log a property from a document, for example:
Create a document in the collection with a curly brace in the name property, e.g. { "name": "Test’s" }
View the log entry for the create.
What I expect to happen
The log entries should show the text using the curly quote, e.g. the output should be:
the string Test’s
the json {"name":"Test’s"}
What actually happens
The log entries show some other encoding mechanism:
the string Testâs
the json {"name":"Testâs"}
Additional details
This is not just a problem of the function log itself being encoded incorrectly: our trigger function pushes the JSON.stringify of the document to SQS, and the encoding shows the incorrect Testâs as well for the message on the SQS queue.
Since I was able to isolate this behavior to the MongoDB Atlas triggered function, I would still like follow-up on what occurred on the MongoDB side, e.g. an incident report, and will comment here if I receive it.
This appears to be an intermittent problem. The two times it happened so far are:
We spotted the problem March 23 at about 09:00 CDT, but by around 14:00 CDT it started working correctly.
Today (March 26) the problem started happening again, from a different Atlas Trigger, roughly around 10:00 CDT, but stopped happening at about 11:30 CDT.
I’ve been able to make a stopgap fix which takes care of the most visible+ugly character encoding problem, using this (not in the Realm function, it’s in an AWS post-process function):