[SERVER-38592] A malformed createIndex doesn't generate an error message and gets executed in the foreground Created: 13/Dec/18  Updated: 06/Dec/22  Resolved: 17/Dec/18

Status: Closed
Project: Core Server
Component/s: Querying, Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Miguel Angel Nieto Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-26726 Check number of arguments for createI... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

The following createIndex is incorrect:

db.collection.createIndex( { "SysTS": 1 }, { expireAfterSeconds: 47335428 }, {background: true} );

Instead of receiving an error, it gets executed in the foreground.

Tested in 3.6 and 4.0.



 Comments   
Comment by Asya Kamsky [ 17/Dec/18 ]

Closing as duplicate, please make comments on SERVER-26726

Comment by Asya Kamsky [ 17/Dec/18 ]

Identical to SERVER-26726 I believe.

Also similar to SERVER-13440 and SERVER-28397 and SERVER-21671 and other helpers which don't look at all the expected passed in options or parameters.

Comment by James Wahlin [ 17/Dec/18 ]

The db.collections.createIndex() shell function is defined as follows and takes 2 arguments:

function (keys, options) {
    return this.createIndexes([keys], options);
}

The invocation provided here passes {background: true} as a third argument which is ignored and not sent to the server as part of the createIndexes command.

In general mongo shell helpers do not validate whether too many arguments have been passed to them. We could consider whether we would like to add validation for this.

Comment by Kelsey Schubert [ 13/Dec/18 ]

dup of SERVER-10075?

Generated at Thu Feb 08 04:49:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.