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

Incorrect parsing of extended JSON $dbPointer

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.3.0
    • Component/s: JSON & ExtJSON
    • 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
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: