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

BSON Library Decoder Panics And Cannot Cast Numbers

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.0.1
    • Affects Version/s: None
    • Component/s: None
    • None

      The two main bugs:

      • The decoder can't properly decode an int32 into a struct field that's an int64. As long as the values fit, we should be able to freely put int32's, int64's, and doubles into the other number types.
      • The decoder cannot handle decoding into a slice when it is a field of a struct. I didn't check for maps, but from the code it looks like whenever a BSON Array is returned and we try to decode it into an array or a slice we panic.

      Additionally, the unit test coverage is sparse. One idea to boost the unit test coverage would be to ensure that we support roundtripping: If a user gives us a struct to encode, we should be able to encode it and then decode back into the same type and the values should be the same. Writing test that cover the happy path for the getReflectValue method would also boost coverage.

      For the slice case, it is okay to create a new slice of the correct length and assign it to the field, if users want to control their allocs they can handle unmarshaling in custom code.

            Assignee:
            sam.rossi@mongodb.com Samuel Rossi (Inactive)
            Reporter:
            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: