Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3253

ToString in BsonDocument ignores subType and always shows the GUID with CSUUID subType even though the value in UUID

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      It's really visible here in debugging: https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver/Encryption/ExplicitEncryptionLibMongoCryptController.cs#L59 where wrappedKeyDocument shows that _id is in CSUUID form. But if we check the _id value itself, it will be in UUID format.

      Simplified test is:

                  var @string = $"{{ '_id' : UUID('3fdabe71-f829-4469-9c5c-15cc4881c50c') }}";
                  var bsonDocument = BsonDocument.Parse(@string);
                  var stringDocument = bsonDocument.ToString();
                  stringDocument.Should().Contain("CSUUID"); // pass
                  stringDocument.Should().NotContain("3fdabe71-f829-4469-9c5c-15cc4881c50c"); // fail, pay attention that guid numbers are the same in both places
      

      NOTE: bytes in both cases are the same, the only difference is subType

      Attachments

        Activity

          People

            Unassigned Unassigned
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: