From 31e93a577b5b1cef58424199d6ed325182db89de Mon Sep 17 00:00:00 2001 From: Sanika Phanse Date: Wed, 17 May 2023 01:29:37 +0000 Subject: SERVER-77197 Change error code to NamespaceNotSharded --- .../cluster_write_without_shard_key_basic.js | 2 +- src/mongo/s/commands/cluster_write_without_shard_key_cmd.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jstests/sharding/updateOne_without_shard_key/cluster_write_without_shard_key_basic.js b/jstests/sharding/updateOne_without_shard_key/cluster_write_without_shard_key_basic.js index 9afeaf3a71d..ea24eee2e23 100644 --- a/jstests/sharding/updateOne_without_shard_key/cluster_write_without_shard_key_basic.js +++ b/jstests/sharding/updateOne_without_shard_key/cluster_write_without_shard_key_basic.js @@ -359,7 +359,7 @@ function runAndVerifyCommand(testCase) { autocommit: false }; mongosConn.getCollection(unshardedCollName).insert([{_id: _id, a: aFieldValue}]); - assert.commandFailedWithCode(mongosConn.runCommand(cmdObj), ErrorCodes.InvalidOptions); + assert.commandFailedWithCode(mongosConn.runCommand(cmdObj), ErrorCodes.NamespaceNotSharded); // Must run in a transaction. cmdObj = { diff --git a/src/mongo/s/commands/cluster_write_without_shard_key_cmd.cpp b/src/mongo/s/commands/cluster_write_without_shard_key_cmd.cpp index 935f41de692..c3668182621 100644 --- a/src/mongo/s/commands/cluster_write_without_shard_key_cmd.cpp +++ b/src/mongo/s/commands/cluster_write_without_shard_key_cmd.cpp @@ -100,7 +100,7 @@ BSONObj _createCmdObj(OperationContext* opCtx, const BSONObj& writeCmd, const BSONObj& targetDocId) { const auto cri = uassertStatusOK(getCollectionRoutingInfoForTxnCmd(opCtx, nss)); - uassert(ErrorCodes::InvalidOptions, + uassert(ErrorCodes::NamespaceNotSharded, "_clusterWriteWithoutShardKey can only be run against sharded collections.", cri.cm.isSharded()); const auto shardVersion = cri.getShardVersion(shardId); -- cgit v1.2.1