[SERVER-8628] collmod expireAfterSeconds should correctly handle bad keyPattern and unrecognized fields Created: 20/Feb/13  Updated: 08/Sep/20  Resolved: 02/Jun/20

Status: Closed
Project: Core Server
Component/s: Admin, TTL
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Bug Priority: Major - P3
Reporter: Gary Murakami Assignee: Gregory Noma
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Minor Change
Operating System: ALL
Sprint: Execution Team 2020-06-15
Participants:

 Description   

The collmod command should handle the following errors more gracefully.
(1) a bad keyPattern should fail with message "keyPattern not found" (it currently fails with message "no keyPattern specified")

> db.runCommand( {collMod: "a", "index" : { "keyPattern" : "bad" , "expireAfterSeconds" : 100 } } )
{ "ok" : 0, "errmsg" : "no keyPattern specified" }

(2) an unrecognized field in the index should fail with message "unrecognized index field (it currently ignores the field and carries on silently)

> db.runCommand( {collMod: "a", "index" : { "keyPattern" : {status:1} , "expireAfterSeconds" : 100, 'foo':1 } } )
{ "ok" : 1 }



 Comments   
Comment by Githook User [ 02/Jun/20 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-8628 Check the index option of collMod for unrecognized fields
Branch: master
https://github.com/mongodb/mongo/commit/50b4d21e4a81d1c2b508772564e029641248f679

Comment by Gary Murakami [ 20/Feb/13 ]

This issue is minor/trivial, only error reporting/handling. Please do not hold up the 2.4 release.

Comment by Gary Murakami [ 20/Feb/13 ]

Ruby code snippets:

(1) { collMod: @coll_name, index:

{ keyPattern: 'bad', expireAfterSeconds: @new_value }

}

(2) { collMod: @coll_name, index:

{ keyPattern: @key_pattern, expireAfterSeconds: @new_value, unknown: 1 }

}

@coll_name, @new_value and @key_pattern are Ruby member variables - you can assume that acceptable values are substituted.

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