[DOCS-12884] Investigate changes in SERVER-41829: findAndModify ignores filter expressions that are not objects Created: 12/Jul/19  Updated: 13/Nov/23  Resolved: 31/Jul/19

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.3.1, 3.6.14, 4.2.0-rc3, 4.0.12, 3.4.23, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: docs-backport-done
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-41829 findAndModify ignores filter expressi... Closed
Participants:
Days since reply: 4 years, 21 weeks, 2 days ago
Epic Link: DOCS: 4.2 Server/Tools

 Description   

Description

Change Description:

This change will start failing if 'filter', 'fields', 'sort' fields of findAndModify are explicitly set to null. This might need an update to existing docs.

SERVER ticket description:

I have some basic users in a collection created by mongoose.  My program code created one incorrectly, so I went into the command line to fix it. (its not a big application). I went to use the db.colleciton.findOneAndDelete(...) first, but it deleted the wrong entry.

I was confused at first, but I didn't craft the query in the argument right to match a record, and it should have errored out. When I use the exact same query string in db.collection.findOne(...) it errors and doesn't continue, but with db.collection.findOneAndDelete(...) it does not error, and appears to delete the first record it found.

 

> db.users
autoradar.users
> db.users.find()
{ "_id" : ObjectId("5cb781472973f80012ea11e5"), "registered" : true, "username" : "hannah", "password" : "-redacted-", "__v" : 0 }
{ "_id" : ObjectId("5d0951717c815e0012af79df"), "registered" : true, "username" : "Harshil ", "password" : "-redacted-", "__v" : 0 }
{ "_id" : ObjectId("5cb4db582973f80012ea11d8"), "registered" : true, "username" : "mac", "password" : "-redacted-", "__v" : 0 }
> db.users.findOne('{ "username" : "mac" }')
2019-06-19T14:14:02.120+0000 E QUERY    [js] Error: error: {
        "ok" : 0,
        "errmsg" : "SyntaxError: missing ; before statement :\nfunctionExpressionParser@src/mongo/scripting/mozjs/mongohelpers.js:48:25\n",
        "code" : 139,
        "codeName" : "JSInterpreterFailure"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCommandCursor@src/mongo/shell/query.js:708:1
DBQuery.prototype._exec@src/mongo/shell/query.js:113:28
DBQuery.prototype.hasNext@src/mongo/shell/query.js:288:5
DBCollection.prototype.findOne@src/mongo/shell/collection.js:260:10
@(shell):1:1
> db.users.findOneAndDelete('{ "username" : "mac" }')
{
        "_id" : ObjectId("5cb781472973f80012ea11e5"),
        "registered" : true,
        "username" : "hannah",
        "password" : "-redacted-",
        "__v" : 0
}
> db.users.find()
{ "_id" : ObjectId("5d0951717c815e0012af79df"), "registered" : true, "username" : "Harshil ", "password" : "-redacted-", "__v" : 0 }
{ "_id" : ObjectId("5cb4db582973f80012ea11d8"), "registered" : true, "username" : "mac", "password" : "-redacted-", "__v" : 0 }

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 16/Sep/19 ]

Author:

{'username': 'kay-kim', 'email': 'kay.kim@10gen.com', 'name': 'Kay Kim'}

Message: DOCS-12884: v3.4.23 findAndModify param validation
Branch: v3.4
https://github.com/mongodb/docs/commit/a54bc72de93b114db4e3f27695fedf06e1f22292

Comment by Githook User [ 26/Aug/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12884: v3.6.14 findAndModify param validation
Branch: v3.6
https://github.com/mongodb/docs/commit/2fcd7e2e1e3c9fbb316b44bb889702a630259249

Comment by Githook User [ 12/Aug/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12884: v3.4.23 findAndModify param validation
Branch: v3.4.23
https://github.com/mongodb/docs/commit/cbdfd4b6a18e6cd623f67dea12f3c71d4935c71c

Comment by Githook User [ 12/Aug/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12884: v4.0.12 findAndModify param validation
Branch: v4.0
https://github.com/mongodb/docs/commit/679cf75bc8477874095fc5b0f9a81e360ef5cce0

Comment by Githook User [ 12/Aug/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12884: v4.0.12 findAndModify param validation
Branch: v4.0
https://github.com/mongodb/docs/commit/886845a7b15d6fad8eacc7fb8116e5f17aeea03d

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: v3.4.23 findAndModify param validation
Branch: v3.4.23
https://github.com/mongodb/docs/commit/1ed785e9059d1d13121065e5c35ddcd02ebba3e8

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: v3.4.23 findAndModify param validation
Branch: v3.4.23
https://github.com/mongodb/docs/commit/7930ee32957921814f1f64941be8a766d17b48b3

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: v3.6.14 findAndModify param validation
Branch: v3.4.23
https://github.com/mongodb/docs/commit/a18e01608cc1582f8a6ca5ca38ada78d33d16c4f

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12884: v3.6.14 findAndModify param validation
Branch: v3.6.14
https://github.com/mongodb/docs/commit/ad07200516cd18b9c5246efa851bcb7abc4033be

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: include the 3.4 backport version info
Branch: master
https://github.com/mongodb/docs/commit/4d3fcef9caebbb8dd78fd45479e618dcea3ef749

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12884: v4.0.12 findAndModify param validation
Branch: v4.0.12
https://github.com/mongodb/docs/commit/7ecc7749a7a8a9092a9a276ee38c18990b54900c

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: v4.0.12 findAndModify param validation
Branch: v4.0.12
https://github.com/mongodb/docs/commit/56a15ff5055ca6a044a8839ad156fd8facb09d02

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: include backport version info
Branch: master
https://github.com/mongodb/docs/commit/c8a250e31a1c35b47f28a102eb6b1c11fc8ebd69

Comment by Githook User [ 31/Jul/19 ]

Author:

{'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}

Message: DOCS-12884: 4.2 findAndModify query/sort validation
Branch: master
https://github.com/mongodb/docs/commit/c835df6b5589fdb86afe26aecfe4486c4660dd88

Generated at Thu Feb 08 08:06:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.