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

Incorrect parsing of extended JSON $dbPointer

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • 1.3.0
    • JSON & ExtJSON
    • None

    Description

      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
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: