-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 1.3.0
-
Component/s: JSON & ExtJSON
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The driver parses a string $id field, but per the spec, this must be an object ID, not a string.
Repro:
package main
import (
"encoding/hex"
"fmt"
"log"
"go.mongodb.org/mongo-driver/bson"
)
func main() {
input := `{"":{"$dbPointer":{"$ref":"","$id":"000000000000000000000000"}}}`
var output bson.Raw
err := bson.UnmarshalExtJSON([]byte(input), false, &output)
if err != nil {
log.Fatal(err)
}
fmt.Println(hex.EncodeToString(output))
}
Output:
180000000c00010000000000000000000000000000000000