-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: None
-
Environment:MongoDB 4.0.1, Node 8
-
Empty show more show less
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!
- duplicates
-
NODE-1645 Bson serialisation throw error on inner keys starting with '$'
- Closed
- is documented by
-
NODE-1652 Document checkKeys = false on write operations
- Backlog
- related to
-
SERVER-30575 Please add escaping convention for dot and dollar signs!
- Backlog