Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2796

Return an error if attempting to decode a BSON object ID as a Go string

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
      None
    • Major Change
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Currently, the Go BSON library allows decoding a BSON ObjectID into a Go string value by default. The resulting string is the hexadecimal representation of the BSON ObjectID bytes. If the DecodeObjectIDAsHex option is disabled (enabled by default), the BSON ObjectID is decoded as the UTF-8 representation of the raw ObjectID bytes, which results in a garbled and unusable string. Instead of defaulting to decoding to a hexadecimal string value, we should return an error by default, and allow decoding to a hexadecimal string as an optional fallback.

      Definition of done:

      • Update the logic here to return an error by default.
      • Add a Decoder.ObjectIDAsHexString method that enables decoding a BSON ObjectID as a hexadecimal string instead of returning an error.

            Assignee:
            qingyang.hu@mongodb.com Qingyang Hu
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: