[SERVER-11986] $ projection operator doesn't validate corresponding field in query specifier in 2.5 Created: 06/Dec/13  Updated: 11/Jul/16  Resolved: 10/Dec/13

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.5.4
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Luke Lovett Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa, nqf, query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> db.serverBuildInfo()
{
"version" : "2.4.9-pre-",
"gitVersion" : "5779b6e198c0dd22a99e12837faea4b5e8b2664f",
"sysInfo" : "Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -rdynamic -m64",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O3 -m64",
"allocator" : "system",
"versionArray" : [
2,
4,
9,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}
and
> db.serverBuildInfo()
{
"version" : "2.5.5-pre-",
"gitVersion" : "7816de1dbc43f93c06cfeb28ab5f7d65009e8372",
"OpenSSLVersion" : "",
"sysInfo" : "Darwin llmac 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -Wl,-bind_at_load -mmacosx-version-min=10.6",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-unused-private-field -Wno-mismatched-tags -Wno-deprecated-declarations -Wno-tautological-constant-out-of-range-compare -mmacosx-version-min=10.6",
"allocator" : "tcmalloc",
"versionArray" : [
2,
5,
5,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}


Attachments: File server11986.js    
Issue Links:
Related
related to SERVER-12027 add elemMatch and slice test cases to... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

2.4.9-pre-

> db.g.insert({arr:[5]})
> db.g.find({arr:{$gt:4}},{"arr.$":1})
{ "_id" : ObjectId("52a1164abed6d595b15ec697"), "arr" : [  5 ] }
> db.g.find({arr:{$size:1}},{"arr.$":1})
error: {
	"$err" : "positional operator (arr.$) requires corresponding field in query specifier",
	"code" : 16352
}

2.5.5-pre-

> db.g.insert({arr:[5]})
Insert WriteResult({ "ok" : 1, "n" : 1 })
> db.g.find({arr:{$gt:4}},{"arr.$":1})
{ "_id" : ObjectId("52a1164add47ad0373e22ae8"), "arr" : [ 5 ] }
> db.g.find({arr:{$size:1}},{"arr.$":1})
{ "_id" : ObjectId("52a1164add47ad0373e22ae8") }

Participants:

 Description   

Version 2.5 of MongoDB doesn't seem to look to see if there's a corresponding field to match with the $ projection operator. Consequently, malformed projections involving the $ operator return documents in version 2.5, but an error is thrown in 2.4.



 Comments   
Comment by Githook User [ 10/Dec/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-11986 return failure on invalid positional $ projection
Branch: master
https://github.com/mongodb/mongo/commit/1772eef330e7ed06700b2d1560f40147412fb685

Generated at Thu Feb 08 03:27:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.