-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
ALL
-
Execution Team 2019-10-21
-
(copied to CRM)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When creating an index, createIndex will validate that the index option keys are valid. The following index definition is not valid because there is no spork option:
> db.COLL.createIndex({a:1},{spork:true})
{
"ok": 0,
"errmsg": "The field 'spork' is not valid for an index specification. Specification: { key: { a: 1.0 }, name: \"a_1\", spork: true }",
"code": 197,
"codeName": "InvalidIndexSpecificationOption"
}
However an invalid option value for a known option key will succeed:
> db.COLL.createIndex({a:1},{sparse:"PanGalacticGargleBlaster"})
{
"createdCollectionAutomatically": true,
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"ok": 1
}
This can cause problems for other tooling that assumes sparse will always be a boolean value. Even more insidious is in cases such as sparse:1 rather than sparse:true.
The same problem can be observed with background and other index options.
- duplicates
-
SERVER-26287 createIndexes should confirm that index options are valid in respect to the underlying collection
-
- Closed
-