I’m getting the error BSONError: Invalid UTF-8 string in BSON document
when using mongosh
and displaying profiling information of the DB through a db.system.profile.find()
.
That should be data created by MongoDB itself, not by us. The data can be properly displayed with the old mongo
shell, so maybe this is a bug within the new mongosh
?
It’s possible to dectivate BSON UTF-8 validation through the new option in the MongoDB driver 4.3.0 according to this release note.
Ex: db.system.profile.find({}, {}, {enableUtf8Validation: false})
The results of the find() query are displayed properly then. But why does MongoDB write invalid UTF-8 to the profiling DB in the first place?
mongosh version: 1.1.8
MongoDB version: 5.0.5