-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
None
-
Go Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
Detailed steps to reproduce the problem?
https://goplay.tools/snippet/W8-KVVAsohX
package main import ( "fmt" "go.mongodb.org/mongo-driver/v2/bson" ) func main() { doc := bson.D{{"foo", 123123}} raw, _ := bson.Marshal(doc) type RT struct { Foo bson.Raw } rt := RT{} err := bson.Unmarshal(raw, &rt) fmt.Printf("Hello, World! (err: %v; rt: %+v)", err, rt) }
Output:
Hello, World! (err: <nil>; rt: {Foo:})
In the above, I expect Unmarshal to fail because it’s trying to unmarshal an int32 (123123) into a Raw, which needs to be a document.
Definition of done: what must be done to consider the task complete?
An appropriate error should be returned.
The exact Go version used, with patch level:
1.25.5
The exact version of the Go driver used:
2.4.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, ...)
n/a
Security Vulnerabilities
Since this puts the application into an internally-invalid state there could be some security implications here, but I can’t think of an actual vulnerability.