Error "Invalid UTF-8 string in BSON document" after rebuild on Windows

Hello.

After successful rebuild mongod.exe 7.0.12 when connecting to MongoDB Compass, the message “Invalid UTF-8 string in BSON document” is displayed.

When rebuilding the sources in Ubuntu, no such message is displayed.

If you take a ready-made exe file, then of course everything works.

The command to build: python buildscripts/scons.py install-mongod MONGO_VERSION=7.0.12 --release --disable-warnings-as-errors --separate-debug=on

Maybe some flag is missing for the build or I’m missing something.

Please tell me, maybe someone has encountered such a problem as it is solved.

Thanks in advance for any hint.

3 Likes

I started to get this same error randomly. Sometimes the string will be parsed correctly, sometimes it won’t, the exact same string.

1 Like

Same here. I’m using docker version (Docker: Accelerated Container Application Development) and after upgrading to v7 started getting same errors. I push data do db using node driver (v6.8) and it should substitute all non utf-8 characters, but apparently it doesn’t. When I use find to extract the data I’m getting Invalid UTF-8 string in BSON document error.

I found out what was going on with it, at least in my case. I remembered that the previous week I had upgraded my Node version from 20 to 22, and when I downgraded it back to 20, the errors stopped.

I’m also on node 22. Any ideas what can cause the issue?

I have no clue. The odd thing about it is that most of the time it would parse the data correctly, and after I while it would start to throw an error when trying to parse the same string as it was parsing before.