Detailed steps to reproduce the problem?
package main import ( "fmt" "go.mongodb.org/mongo-driver/v2/bson" ) func main() { doc := bson.D{{"foo", nil}} raw, _ := bson.Marshal(doc) var val struct { Foo bson.Raw } err := bson.Unmarshal(raw, &val) assert.NoError(t, err) assert.Nil(t, val.Foo) }
The current implementation returns an error: error decoding key foo: cannot decode null into a bson.Raw
Definition of done: what must be done to consider the task complete?
Null should be unmarshalled to a nil bson.Raw. Add tests to cover this scenario.
The exact Go version used, with patch level:
The exact version of the Go driver used:
The issue was introduced in https://github.com/mongodb/mongo-go-driver/pull/2318, and release in 2.5.1
Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.
na
The operating system and version (e.g. Windows 7, OSX 10.8, ...)
na
Security Vulnerabilities
If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here
- related to
-
GODRIVER-3768 Unmarshal() doesn’t fail when unmarshaling int32 to Raw
-
- Closed
-