Details
Description
The server can return an error message suggesting that FCV "3.6" must be set, despite the FCV already being set to "3.6":
> db.adminCommand({setFeatureCompatibilityVersion: "3.6"})
|
{ "ok" : 1 }
|
> db.c.aggregate([{$match: {$jsonSchema: {}}}])
|
assert: command failed: {
|
"ok" : 0,
|
"errmsg" : "The featureCompatiblityVersion must be 3.6 to use $jsonSchema. See http://dochub.mongodb.org/core/3.6-feature-compatibility.",
|
"code" : 2,
|
"codeName" : "BadValue"
|
} : aggregate failed
|
_getErrorWithCode@src/mongo/shell/utils.js:25:13
|
doassert@src/mongo/shell/assert.js:16:14
|
assert.commandWorked@src/mongo/shell/assert.js:403:5
|
DB.prototype._runAggregate@src/mongo/shell/db.js:257:9
|
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1285:12
|
@(shell):1:1
|
|
|
2017-09-07T13:09:57.953-0400 E QUERY [thread1] Error: command failed: {
|
"ok" : 0,
|
"errmsg" : "The featureCompatiblityVersion must be 3.6 to use $jsonSchema. See http://dochub.mongodb.org/core/3.6-feature-compatibility.",
|
"code" : 2,
|
"codeName" : "BadValue"
|
} : aggregate failed :
|
_getErrorWithCode@src/mongo/shell/utils.js:25:13
|
doassert@src/mongo/shell/assert.js:16:14
|
assert.commandWorked@src/mongo/shell/assert.js:403:5
|
DB.prototype._runAggregate@src/mongo/shell/db.js:257:9
|
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1285:12
|
@(shell):1:1
|
The problem is that this error message is currently returned for any caller of the match expression parser which bans JSON Schema:
https://github.com/mongodb/mongo/blob/master/src/mongo/db/matcher/expression_parser.cpp#L578-L585
This error message, however, should be specific to the collMod and create collection call sites which have FCV-related checks. Other call sites which may ban JSON Schema should have a more general message like "$jsonSchema not allowed in this context".