Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1650

Node driver does not allow nested keys starting with dollar signs ('$')

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      MongoDB 4.0.1, Node 8

      MongoDB allows keys that start with dollar signs:

      Field names can contain dots (i.e. .) and dollar signs (i.e. $). However, only nested field names may start with a dollar sign. For example, attempting to insert {{{ "a" :

      Unknown macro: { "$b"}

      }}} will succeed but attempting to insert {{

      Unknown macro: {"$a"}

      }} results in error.

      Source: https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names

      Trying to insert {{{ "a" :

      { "$b": 1 }

      }}} as mentioned above, the Node driver throws the following error:

       

      Error: key $b must not start with '$'
          at serializeInto (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:912:19)
          at serializeObject (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:348:18)
          at serializeInto (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:938:17)
          at serializeObject (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:348:18)
          at serializeInto (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:728:17)
          at serializeObject (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:348:18)
          at serializeInto (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js:938:17)
          at BSON.serialize (/usr/src/app/node_modules/mongodb-core/node_modules/bson/lib/bson/bson.js:63:28)
          at Query.toBin (/usr/src/app/node_modules/mongodb-core/lib/connection/commands.js:146:25)
          at serializeCommands (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:1045:43)
          at Pool.write (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:1261:3)
          at executeWrite (/usr/src/app/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:147:10)
          at WireProtocol.insert (/usr/src/app/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:158:3)
          at Server.insert (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:815:35)
          at Server.insert (/usr/src/app/node_modules/mongodb/lib/topologies/topology_base.js:321:25)
          at insertDocuments (/usr/src/app/node_modules/mongodb/lib/operations/collection_ops.js:822:19) 
      

      This is a serious regression, especially combined with https://jira.mongodb.org/browse/NODE-1649!

       

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            nikwen Niklas Wenzel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: