Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3627

Getting "Invalid UTF-8 string in BSON document" instead on unique constraint error on bulkWrite.replaceOne

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.2.1
    • Affects Version/s: None
    • Component/s: None
    • Needed

      What problem are you facing?

      I have a bulkWrite operation that worked perfectly with MongoDB 4.4 / Mongo Client 3.5. But after upgrading to MongoDB 5 / Mongo Client 4.1.2 it doesn't.

      The issue is, when I have a replaceOne operation in a bulkWrite that violates unique index constraint, I used to get an error describing the index name that causes the conflict. In the new setup I'm just getting this "Invalid UTF-8 string in BSON document" error. If I go, and comment out BSON parser's desiriazer.js around line 100 where you check that 0xfffd (the whole for block), everything works perfectly I'm getting the correct error message again.

      So I believe this error is not a user error. The client has issues while parsing valid MongoDB error messages.

      What driver and relevant dependency versions are you using?

      MongoDB client 4.1.2

      MongoDB 5.0

      Steps to reproduce?

      See description.

            Assignee:
            grace.chong@mongodb.com Grace Chong (Inactive)
            Reporter:
            gabor42mezo@gmail.com Gábor Mező
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: