summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2021-11-01 14:45:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-01 15:19:49 +0000
commit37d7d7041acf6bd7d32323ca84668061cdb1147b (patch)
tree106684946598076a044109815529d8091177c964
parent4a2038826d71171cf4f1fa1ec5afc01697d36b1f (diff)
downloadmongo-37d7d7041acf6bd7d32323ca84668061cdb1147b.tar.gz
SERVER-60179 The 'validate' command should return 'InvalidOptions' instead of 'CommandNotSupported' for incompatible options
-rw-r--r--jstests/noPassthrough/background_validation_repl.js2
-rw-r--r--jstests/noPassthrough/validate_detects_invalid_index_options.js8
-rw-r--r--jstests/noPassthroughWithMongod/background_validation.js2
-rw-r--r--src/mongo/db/commands/validate.cpp12
4 files changed, 12 insertions, 12 deletions
diff --git a/jstests/noPassthrough/background_validation_repl.js b/jstests/noPassthrough/background_validation_repl.js
index 8d3eb39e8f2..673e7e79a2c 100644
--- a/jstests/noPassthrough/background_validation_repl.js
+++ b/jstests/noPassthrough/background_validation_repl.js
@@ -60,7 +60,7 @@ const doTest = replSet => {
* Ensure {full:true} and {background:true} cannot be run together.
*/
assert.commandFailedWithCode(testColl.validate({background: true, full: true}),
- ErrorCodes.CommandNotSupported);
+ ErrorCodes.InvalidOptions);
assert.commandWorked(testDB.adminCommand({fsync: 1}));
diff --git a/jstests/noPassthrough/validate_detects_invalid_index_options.js b/jstests/noPassthrough/validate_detects_invalid_index_options.js
index c8a3e495bb0..98ae6130209 100644
--- a/jstests/noPassthrough/validate_detects_invalid_index_options.js
+++ b/jstests/noPassthrough/validate_detects_invalid_index_options.js
@@ -43,14 +43,14 @@ checkLog.containsJson(conn, 5980501);
// foreground validation on the ephemeralForTest storage engine, making it incompatible with this
// test.
assert.commandFailedWithCode(db.runCommand({validate: collName, metadata: true, background: true}),
- ErrorCodes.CommandNotSupported);
+ ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(db.runCommand({validate: collName, metadata: true, repair: true}),
- ErrorCodes.CommandNotSupported);
+ ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(db.runCommand({validate: collName, metadata: true, full: true}),
- ErrorCodes.CommandNotSupported);
+ ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(
db.runCommand({validate: collName, metadata: true, enforceFastCount: true}),
- ErrorCodes.CommandNotSupported);
+ ErrorCodes.InvalidOptions);
// Drop the index with the invalid index options and validate only the metadata.
assert.commandWorked(coll.dropIndex({x: 1}));
diff --git a/jstests/noPassthroughWithMongod/background_validation.js b/jstests/noPassthroughWithMongod/background_validation.js
index dfb9a0aa05e..c47ee69c154 100644
--- a/jstests/noPassthroughWithMongod/background_validation.js
+++ b/jstests/noPassthroughWithMongod/background_validation.js
@@ -41,7 +41,7 @@ for (let i = 0; i < numDocs; ++i) {
* Ensure {full:true} and {background:true} cannot be run together.
*/
assert.commandFailedWithCode(testColl.validate({background: true, full: true}),
- ErrorCodes.CommandNotSupported);
+ ErrorCodes.InvalidOptions);
forceCheckpoint();
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp
index f00ed058f94..fb494ab74eb 100644
--- a/src/mongo/db/commands/validate.cpp
+++ b/src/mongo/db/commands/validate.cpp
@@ -135,33 +135,33 @@ public:
const bool fullValidate = cmdObj["full"].trueValue();
if (background && fullValidate) {
- uasserted(ErrorCodes::CommandNotSupported,
+ uasserted(ErrorCodes::InvalidOptions,
str::stream() << "Running the validate command with both { background: true }"
<< " and { full: true } is not supported.");
}
const bool enforceFastCount = cmdObj["enforceFastCount"].trueValue();
if (background && enforceFastCount) {
- uasserted(ErrorCodes::CommandNotSupported,
+ uasserted(ErrorCodes::InvalidOptions,
str::stream() << "Running the validate command with both { background: true }"
<< " and { enforceFastCount: true } is not supported.");
}
const bool repair = cmdObj["repair"].trueValue();
if (background && repair) {
- uasserted(ErrorCodes::CommandNotSupported,
+ uasserted(ErrorCodes::InvalidOptions,
str::stream() << "Running the validate command with both {background: true }"
<< " and { repair: true } is not supported.");
}
if (enforceFastCount && repair) {
- uasserted(ErrorCodes::CommandNotSupported,
+ uasserted(ErrorCodes::InvalidOptions,
str::stream()
<< "Running the validate command with both {enforceFastCount: true }"
<< " and { repair: true } is not supported.");
}
repl::ReplicationCoordinator* replCoord = repl::ReplicationCoordinator::get(opCtx);
if (repair && replCoord->isReplEnabled()) {
- uasserted(ErrorCodes::CommandNotSupported,
+ uasserted(ErrorCodes::InvalidOptions,
str::stream()
<< "Running the validate command with { repair: true } can only be"
<< " performed in standalone mode.");
@@ -169,7 +169,7 @@ public:
const bool metadata = cmdObj["metadata"].trueValue();
if (metadata && (background || fullValidate || enforceFastCount || repair)) {
- uasserted(ErrorCodes::CommandNotSupported,
+ uasserted(ErrorCodes::InvalidOptions,
str::stream() << "Running the validate command with { metadata: true } is not"
<< " supported with any other options");
}