-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Detailed steps to reproduce the problem?
Run the following with v2.5.0:
package main import ( "fmt" "github.com/samber/lo" "go.mongodb.org/mongo-driver/v2/bson" ) func main() { doc := bson.D{{"doc", nil}} bin, err := bson.Marshal(doc) lo.Assertf(err == nil, "marshal: %v", err) rt := struct { Doc bson.Raw }{} err = bson.Unmarshal(bin, &rt) lo.Assertf(err == nil, "unmarshal: %v", err) fmt.Printf("rt: %#v\n", rt.Doc) }
You'll see:
rt: bson.Raw{}
Run it against v2.7.0 of the driver, though, and you'll see:
rt: bson.Raw(nil)
This behavior change, however subtle, seems an unintended effect of GODRIVER-3924.
It’s a breaking change, and one that (AFAICT) doesn’t fix anything with regard to the driver spec, so per semver the v2 driver probably should revert to v2.5.0’s behavior. v2.7.0’s behavior should be part of driver v3.
Definition of done: what must be done to consider the task complete?
Either:
- Restore v2.5.0's behavior, OR:
- Determine that the new behavior—which, all things aside, does seem more sensible—is the new norm
The exact Go version used, with patch level:
1.26.3
The exact version of the Go driver used:
v2.5.0 & v2.7.0
Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.
n/a
The operating system and version (e.g. Windows 7, OSX 10.8, ...)
macOS Sequoia
Security Vulnerabilities
n/a
- related to
-
GODRIVER-3924 Unmarshal() should not fail when unmarshaling null to Raw
-
- Closed
-