summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/decimal/decimal_feature_compatibility_version.js8
-rw-r--r--src/mongo/db/dbmessage.cpp11
-rw-r--r--src/mongo/db/dbmessage_test.cpp2
3 files changed, 8 insertions, 13 deletions
diff --git a/jstests/decimal/decimal_feature_compatibility_version.js b/jstests/decimal/decimal_feature_compatibility_version.js
index 0b9d1903704..66f07f9581d 100644
--- a/jstests/decimal/decimal_feature_compatibility_version.js
+++ b/jstests/decimal/decimal_feature_compatibility_version.js
@@ -28,12 +28,8 @@
assert.eq("3.2", res.featureCompatibilityVersion);
// Decimals cannot be inserted when the featureCompatibilityVersion is 3.2.
- // TODO SERVER-23972: Inserting decimals should also fail in legacy write mode when
- // featureCompatibilityVersion is 3.2.
- if (decimalDB.getMongo().writeMode() === "commands") {
- assert.writeErrorWithCode(decimalDB.collection.insert({a: NumberDecimal(2.0)}),
- ErrorCodes.InvalidBSON);
- }
+ assert.writeErrorWithCode(decimalDB.collection.insert({a: NumberDecimal(2.0)}),
+ ErrorCodes.InvalidBSON);
// Decimals cannot be used in queries when the featureCompatibilityVersion is 3.2.
assert.throws(function() {
diff --git a/src/mongo/db/dbmessage.cpp b/src/mongo/db/dbmessage.cpp
index 4b5f5054ccf..182d538764b 100644
--- a/src/mongo/db/dbmessage.cpp
+++ b/src/mongo/db/dbmessage.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/dbmessage.h"
#include "mongo/db/operation_context.h"
#include "mongo/platform/strnlen.h"
+#include "mongo/rpc/object_check.h"
#include "mongo/transport/session.h"
namespace mongo {
@@ -120,16 +121,14 @@ const char* DbMessage::getArray(size_t count) const {
}
BSONObj DbMessage::nextJsObj() {
- massert(10304,
+ uassert(ErrorCodes::InvalidBSON,
"Client Error: Remaining data too small for BSON object",
_nextjsobj != NULL && _theEnd - _nextjsobj >= 5);
if (serverGlobalParams.objcheck) {
- // TODO SERVER-23972: Change BSONVersion::kLatest to
- // Validator<BSONObj>::enabledBSONVersion() so that we disallow decimal inserts in legacy
- // write mode if decimal is disabled.
- Status status = validateBSON(_nextjsobj, _theEnd - _nextjsobj, BSONVersion::kLatest);
- massert(10307,
+ Status status = validateBSON(
+ _nextjsobj, _theEnd - _nextjsobj, Validator<BSONObj>::enabledBSONVersion());
+ uassert(ErrorCodes::InvalidBSON,
str::stream() << "Client Error: bad object in message: " << status.reason(),
status.isOK());
}
diff --git a/src/mongo/db/dbmessage_test.cpp b/src/mongo/db/dbmessage_test.cpp
index c0d40f49bde..2afd69b06ea 100644
--- a/src/mongo/db/dbmessage_test.cpp
+++ b/src/mongo/db/dbmessage_test.cpp
@@ -135,7 +135,7 @@ TEST(DBMessage1, GoodInsert2) {
ASSERT_EQUALS(39, d1.pullInt());
BSONObj bo2 = d1.nextJsObj();
- ASSERT_THROWS(d1.nextJsObj(), MsgAssertionException);
+ ASSERT_THROWS(d1.nextJsObj(), UserException);
}