-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: BSON
-
None
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.