Avoid improper marshal/unmarshal of ReadConcern & WriteConcern

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • None
    • None
    • Go Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Currently the driver allows marshaling the WriteConcern struct but doesn’t convert the Journal struct member to `j` … which can produce an invalid `writeConcern` BSON document.

      This is important because users who call RunCommand() are fairly likely to do something like:

      RunCommand(
          ctx,
          bson.D{
              update: "mycoll",
              updates: []bson.D{ … },
              writeConcern: writeconcern.Majority(),
          },
      )
      

      … which right now happens to work, but if there’s anything in the WriteConcern.Journal field then an invalid BSON document will result. (I believe WTimeout is also improperly marshaled since it’s a Duration, and the expected value is a # of milliseconds.)

      I believe something similar may affect ReadConcern. There, though, per matt.dale@mongodb.com it’s actually not possible to marshal the document reliably/completely. In that case, mayhap an error-returning MarshalBSON() method would be indicated?

      Definition of done

      Marshaling a WriteConcern or a ReadConcern should return either an error or a correct result, not an incorrect document.

            Assignee:
            Unassigned
            Reporter:
            Felipe Gasper
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: