diff options
| author | Hugh Tong <hugh.tong@mongodb.com> | 2022-07-26 19:20:58 +0000 |
|---|---|---|
| committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-07-26 21:00:49 +0000 |
| commit | 044d2f734e0dba40b9dfb02cc49c2bff8f575cd5 (patch) | |
| tree | eb2d17564a0c99d2ee9ea3d2f95c81c46bcfcee1 /src | |
| parent | 921bba175902f9b9f29751a466383c3d7e80df7b (diff) | |
| download | mongo-044d2f734e0dba40b9dfb02cc49c2bff8f575cd5.tar.gz | |
SERVER-67824 Rename IDLParserErrorContext to IDLParserContext
Diffstat (limited to 'src')
253 files changed, 636 insertions, 679 deletions
diff --git a/src/mongo/client/read_preference.cpp b/src/mongo/client/read_preference.cpp index 6851e1a8af7..124d7a0ac83 100644 --- a/src/mongo/client/read_preference.cpp +++ b/src/mongo/client/read_preference.cpp @@ -67,7 +67,7 @@ TagSet defaultTagSetForMode(ReadPreference mode) { Status validateReadPreferenceMode(const std::string& prefStr) { try { - ReadPreference_parse(IDLParserErrorContext(kModeFieldName), prefStr); + ReadPreference_parse(IDLParserContext(kModeFieldName), prefStr); } catch (DBException& e) { return e.toStatus(); } @@ -123,7 +123,7 @@ StatusWith<ReadPreferenceSetting> ReadPreferenceSetting::fromInnerBSON(const BSO ReadPreference mode; try { - mode = ReadPreference_parse(IDLParserErrorContext(kModeFieldName), modeStr); + mode = ReadPreference_parse(IDLParserContext(kModeFieldName), modeStr); } catch (DBException& e) { return e.toStatus().withContext( str::stream() << "Could not parse $readPreference mode '" << modeStr @@ -144,8 +144,8 @@ StatusWith<ReadPreferenceSetting> ReadPreferenceSetting::fromInnerBSON(const BSO << " field must be of type object if provided; found " << hedgingModeEl); } - hedgingMode = HedgingMode::parse(IDLParserErrorContext(kHedgeFieldName), - hedgingModeEl.embeddedObject()); + hedgingMode = + HedgingMode::parse(IDLParserContext(kHedgeFieldName), hedgingModeEl.embeddedObject()); if (hedgingMode->getEnabled() && mode == ReadPreference::PrimaryOnly) { return { ErrorCodes::InvalidOptions, diff --git a/src/mongo/client/sasl_aws_client_protocol.cpp b/src/mongo/client/sasl_aws_client_protocol.cpp index 6148b8a439e..60fb0250816 100644 --- a/src/mongo/client/sasl_aws_client_protocol.cpp +++ b/src/mongo/client/sasl_aws_client_protocol.cpp @@ -99,7 +99,7 @@ template <typename T> AWSCredentials parseCredentials(StringData data) { BSONObj obj = fromjson(data.toString()); - auto creds = T::parse(IDLParserErrorContext("security-credentials"), obj); + auto creds = T::parse(IDLParserContext("security-credentials"), obj); return AWSCredentials(creds.getAccessKeyId().toString(), creds.getSecretAccessKey().toString(), diff --git a/src/mongo/client/sasl_aws_protocol_common.h b/src/mongo/client/sasl_aws_protocol_common.h index 1f36f83ece2..43ce95ff80e 100644 --- a/src/mongo/client/sasl_aws_protocol_common.h +++ b/src/mongo/client/sasl_aws_protocol_common.h @@ -79,7 +79,7 @@ T convertFromByteString(StringData rawString) { auto clientFirstBson = cdr.read<Validated<BSONObj>>(); - return T::parse(IDLParserErrorContext("sasl"), clientFirstBson); + return T::parse(IDLParserContext("sasl"), clientFirstBson); } /** diff --git a/src/mongo/client/sdam/sdam_datatypes.h b/src/mongo/client/sdam/sdam_datatypes.h index eae4bc4767a..b70bcb2e8ea 100644 --- a/src/mongo/client/sdam/sdam_datatypes.h +++ b/src/mongo/client/sdam/sdam_datatypes.h @@ -85,7 +85,7 @@ public: : _server(std::move(server)), _success(true), _response(response), _rtt(rtt) { const auto topologyVersionField = response.getField("topologyVersion"); if (topologyVersionField) { - _topologyVersion = TopologyVersion::parse(IDLParserErrorContext("TopologyVersion"), + _topologyVersion = TopologyVersion::parse(IDLParserContext("TopologyVersion"), topologyVersionField.Obj()); } } @@ -95,7 +95,7 @@ public: : _server(std::move(server)), _success(false), _errorMsg(errorMsg) { const auto topologyVersionField = response.getField("topologyVersion"); if (topologyVersionField) { - _topologyVersion = TopologyVersion::parse(IDLParserErrorContext("TopologyVersion"), + _topologyVersion = TopologyVersion::parse(IDLParserContext("TopologyVersion"), topologyVersionField.Obj()); } } diff --git a/src/mongo/client/sdam/server_description_test.cpp b/src/mongo/client/sdam/server_description_test.cpp index b4cbc940c28..ef0074377f6 100644 --- a/src/mongo/client/sdam/server_description_test.cpp +++ b/src/mongo/client/sdam/server_description_test.cpp @@ -510,9 +510,8 @@ TEST_F(ServerDescriptionTestFixture, ShouldStoreTopologyVersion) { auto response = HelloOutcome(HostAndPort("foo:1234"), kTopologyVersion, duration_cast<HelloRTT>(mongo::Milliseconds(40))); - auto topologyVersion = - TopologyVersion::parse(IDLParserErrorContext("TopologyVersion"), - kTopologyVersion.getObjectField("topologyVersion")); + auto topologyVersion = TopologyVersion::parse( + IDLParserContext("TopologyVersion"), kTopologyVersion.getObjectField("topologyVersion")); auto description = ServerDescription(clockSource, response, boost::none /*lastRtt*/, topologyVersion); diff --git a/src/mongo/client/server_discovery_monitor.cpp b/src/mongo/client/server_discovery_monitor.cpp index 7c5921c4dab..cc4821d0cac 100644 --- a/src/mongo/client/server_discovery_monitor.cpp +++ b/src/mongo/client/server_discovery_monitor.cpp @@ -276,7 +276,7 @@ StatusWith<TaskExecutor::CallbackHandle> SingleServerDiscoveryMonitor::_schedule auto responseTopologyVersion = result.response.data.getField("topologyVersion"); if (responseTopologyVersion) { self->_topologyVersion = TopologyVersion::parse( - IDLParserErrorContext("TopologyVersion"), responseTopologyVersion.Obj()); + IDLParserContext("TopologyVersion"), responseTopologyVersion.Obj()); } else { self->_topologyVersion = boost::none; } @@ -334,7 +334,7 @@ StatusWith<TaskExecutor::CallbackHandle> SingleServerDiscoveryMonitor::_schedule auto responseTopologyVersion = result.response.data.getField("topologyVersion"); if (responseTopologyVersion) { self->_topologyVersion = TopologyVersion::parse( - IDLParserErrorContext("TopologyVersion"), responseTopologyVersion.Obj()); + IDLParserContext("TopologyVersion"), responseTopologyVersion.Obj()); } else { self->_topologyVersion = boost::none; } diff --git a/src/mongo/crypto/fle_crypto.cpp b/src/mongo/crypto/fle_crypto.cpp index 555c27e9baf..9f0b0acca51 100644 --- a/src/mongo/crypto/fle_crypto.cpp +++ b/src/mongo/crypto/fle_crypto.cpp @@ -1796,7 +1796,7 @@ BSONObj ECOCCollection::generateDocument(StringData fieldName, ConstDataRange pa } ECOCCompactionDocument ECOCCollection::parseAndDecrypt(const BSONObj& doc, ECOCToken token) { - IDLParserErrorContext ctx("root"); + IDLParserContext ctx("root"); auto ecocDoc = EcocDocument::parse(ctx, doc); auto swTokens = EncryptedStateCollectionTokens::decryptAndParse(token, ecocDoc.getValue()); @@ -2354,7 +2354,7 @@ EncryptedFieldConfig EncryptionInformationHelpers::getAndValidateSchema( "Expected an object for schema in EncryptionInformation", !element.eoo() && element.type() == Object); - auto efc = EncryptedFieldConfig::parse(IDLParserErrorContext("schema"), element.Obj()); + auto efc = EncryptedFieldConfig::parse(IDLParserContext("schema"), element.Obj()); uassert(6371206, "Expected a value for eccCollection", efc.getEccCollection().has_value()); uassert(6371207, "Expected a value for escCollection", efc.getEscCollection().has_value()); @@ -2369,7 +2369,7 @@ std::pair<EncryptedBinDataType, ConstDataRange> fromEncryptedConstDataRange(Cons uint8_t subTypeByte = cdrc.readAndAdvance<uint8_t>(); - auto subType = EncryptedBinDataType_parse(IDLParserErrorContext("subtype"), subTypeByte); + auto subType = EncryptedBinDataType_parse(IDLParserContext("subtype"), subTypeByte); return {subType, cdrc}; } @@ -2402,8 +2402,7 @@ StringMap<FLEDeleteToken> EncryptionInformationHelpers::getDeleteTokens( for (const auto& deleteTokenBSON : element.Obj()) { uassert(6371310, "DeleteToken is not an object", deleteTokenBSON.type() == Object); - auto payload = - FLE2DeletePayload::parse(IDLParserErrorContext("delete"), deleteTokenBSON.Obj()); + auto payload = FLE2DeletePayload::parse(IDLParserContext("delete"), deleteTokenBSON.Obj()); auto deleteToken = FLEDeleteToken{FLETokenFromCDR<FLETokenType::ECOCToken>(payload.getEcocToken()), diff --git a/src/mongo/crypto/fle_crypto.h b/src/mongo/crypto/fle_crypto.h index 7b2b63a4712..c3bac17c09c 100644 --- a/src/mongo/crypto/fle_crypto.h +++ b/src/mongo/crypto/fle_crypto.h @@ -1202,7 +1202,7 @@ T parseFromCDR(ConstDataRange cdr) { ConstDataRangeCursor cdc(cdr); auto obj = cdc.readAndAdvance<Validated<BSONObj>>(); - IDLParserErrorContext ctx("root"); + IDLParserContext ctx("root"); return T::parse(ctx, obj); } diff --git a/src/mongo/crypto/fle_crypto_test.cpp b/src/mongo/crypto/fle_crypto_test.cpp index 9e9b4d9269f..2d234f62ae5 100644 --- a/src/mongo/crypto/fle_crypto_test.cpp +++ b/src/mongo/crypto/fle_crypto_test.cpp @@ -1260,7 +1260,7 @@ EncryptedFieldConfig getTestEncryptedFieldConfig() { ] })"; - return EncryptedFieldConfig::parse(IDLParserErrorContext("root"), fromjson(schema)); + return EncryptedFieldConfig::parse(IDLParserContext("root"), fromjson(schema)); } TEST(EncryptionInformation, RoundTrip) { @@ -1271,7 +1271,7 @@ TEST(EncryptionInformation, RoundTrip) { EncryptedFieldConfig efc2 = EncryptionInformationHelpers::getAndValidateSchema( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)); + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)); ASSERT_BSONOBJ_EQ(efc.toBSON(), efc2.toBSON()); } @@ -1287,7 +1287,7 @@ TEST(EncryptionInformation, BadSchema) { NamespaceString ns("test.test"); ASSERT_THROWS_CODE(EncryptionInformationHelpers::getAndValidateSchema( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)), + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)), DBException, 6371205); } @@ -1300,7 +1300,7 @@ TEST(EncryptionInformation, MissingStateCollection) { efc.setEscCollection(boost::none); auto obj = EncryptionInformationHelpers::encryptionInformationSerialize(ns, efc); ASSERT_THROWS_CODE(EncryptionInformationHelpers::getAndValidateSchema( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)), + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)), DBException, 6371207); } @@ -1309,7 +1309,7 @@ TEST(EncryptionInformation, MissingStateCollection) { efc.setEccCollection(boost::none); auto obj = EncryptionInformationHelpers::encryptionInformationSerialize(ns, efc); ASSERT_THROWS_CODE(EncryptionInformationHelpers::getAndValidateSchema( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)), + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)), DBException, 6371206); } @@ -1318,7 +1318,7 @@ TEST(EncryptionInformation, MissingStateCollection) { efc.setEcocCollection(boost::none); auto obj = EncryptionInformationHelpers::encryptionInformationSerialize(ns, efc); ASSERT_THROWS_CODE(EncryptionInformationHelpers::getAndValidateSchema( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)), + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)), DBException, 6371208); } @@ -1412,7 +1412,7 @@ TEST(DeleteTokens, Fetch) { EncryptionInformationHelpers::encryptionInformationSerializeForDelete(ns, efc, &keyVault); auto tokenMap = EncryptionInformationHelpers::getDeleteTokens( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)); + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)); ASSERT_EQ(tokenMap.size(), 2); @@ -1815,7 +1815,7 @@ TEST(FLE_Update, PullTokens) { EncryptionInformationHelpers::encryptionInformationSerializeForDelete(ns, efc, &keyVault); auto tokenMap = EncryptionInformationHelpers::getDeleteTokens( - ns, EncryptionInformation::parse(IDLParserErrorContext("foo"), obj)); + ns, EncryptionInformation::parse(IDLParserContext("foo"), obj)); ASSERT_EQ(tokenMap.size(), 2); diff --git a/src/mongo/crypto/fle_data_frames.h b/src/mongo/crypto/fle_data_frames.h index 897f273198a..037574a5d4b 100644 --- a/src/mongo/crypto/fle_data_frames.h +++ b/src/mongo/crypto/fle_data_frames.h @@ -136,7 +136,7 @@ public: uint8_t* getCiphertextMutable() && = delete; FleAlgorithmInt getFLEAlgorithmType() { - return FleAlgorithmInt_parse(IDLParserErrorContext("root"), _data[0]); + return FleAlgorithmInt_parse(IDLParserContext("root"), _data[0]); } size_t getDataLength() const { @@ -204,7 +204,7 @@ public: private: FleAlgorithmInt getFLEAlgorithmType() const { - return FleAlgorithmInt_parse(IDLParserErrorContext("root"), *_data.data<uint8_t>()); + return FleAlgorithmInt_parse(IDLParserContext("root"), *_data.data<uint8_t>()); } size_t getDataLength() const { diff --git a/src/mongo/db/auth/action_type.cpp b/src/mongo/db/auth/action_type.cpp index 6f82948cef4..3b660418205 100644 --- a/src/mongo/db/auth/action_type.cpp +++ b/src/mongo/db/auth/action_type.cpp @@ -47,7 +47,7 @@ constexpr StringData kAction = "action"_sd; StatusWith<ActionType> parseActionFromString(StringData action) { try { - return {ActionType_parse(IDLParserErrorContext(kAction), action)}; + return {ActionType_parse(IDLParserContext(kAction), action)}; } catch (DBException&) { // ignore } diff --git a/src/mongo/db/auth/address_restriction.cpp b/src/mongo/db/auth/address_restriction.cpp index 6a120f97d5f..e8fd687bc75 100644 --- a/src/mongo/db/auth/address_restriction.cpp +++ b/src/mongo/db/auth/address_restriction.cpp @@ -43,7 +43,7 @@ constexpr mongo::StringData mongo::address_restriction_detail::ServerAddress::fi mongo::StatusWith<mongo::RestrictionSet<>> mongo::parseAddressRestrictionSet( const BSONObj& obj) try { - IDLParserErrorContext ctx("address restriction"); + IDLParserContext ctx("address restriction"); const auto ar = Address_restriction::parse(ctx, obj); std::vector<std::unique_ptr<NamedRestriction>> vec; @@ -105,7 +105,7 @@ mongo::StatusWith<mongo::BSONArray> mongo::getRawAuthenticationRestrictions( "'authenticationRestrictions' array sub-documents must be address " "restriction objects"); } - IDLParserErrorContext ctx("address restriction"); + IDLParserContext ctx("address restriction"); auto const ar = Address_restriction::parse(ctx, elem.Obj()); if (auto const&& client = ar.getClientSource()) { // Validate diff --git a/src/mongo/db/auth/authorization_manager_impl.cpp b/src/mongo/db/auth/authorization_manager_impl.cpp index 2d1d6117736..e82202e1f8f 100644 --- a/src/mongo/db/auth/authorization_manager_impl.cpp +++ b/src/mongo/db/auth/authorization_manager_impl.cpp @@ -319,7 +319,7 @@ auto authorizationManagerCreateRegistration = MONGO_FAIL_POINT_DEFINE(waitForUserCacheInvalidation); void handleWaitForUserCacheInvalidation(OperationContext* opCtx, const UserHandle& user) { auto fp = waitForUserCacheInvalidation.scopedIf([&](const auto& bsonData) { - IDLParserErrorContext ctx("waitForUserCacheInvalidation"); + IDLParserContext ctx("waitForUserCacheInvalidation"); auto data = WaitForUserCacheInvalidationFailPoint::parse(ctx, bsonData); const auto& blockedUserName = data.getUserName(); diff --git a/src/mongo/db/auth/authz_manager_external_state_local.cpp b/src/mongo/db/auth/authz_manager_external_state_local.cpp index 3b83db152c6..c860cb839b2 100644 --- a/src/mongo/db/auth/authz_manager_external_state_local.cpp +++ b/src/mongo/db/auth/authz_manager_external_state_local.cpp @@ -223,7 +223,7 @@ void handleAuthLocalGetUserFailPoint(const std::vector<RoleName>& directRoles) { return; } - IDLParserErrorContext ctx("authLocalGetUser"); + IDLParserContext ctx("authLocalGetUser"); auto delay = AuthLocalGetUserFailPoint::parse(ctx, sfp.getData()).getResolveRolesDelayMS(); if (delay <= 0) { diff --git a/src/mongo/db/auth/sasl_commands.cpp b/src/mongo/db/auth/sasl_commands.cpp index db8d9260b1d..17e22efac10 100644 --- a/src/mongo/db/auth/sasl_commands.cpp +++ b/src/mongo/db/auth/sasl_commands.cpp @@ -298,8 +298,8 @@ void doSpeculativeSaslStart(OperationContext* opCtx, AuthenticationSession::doStep( opCtx, AuthenticationSession::StepType::kSpeculativeSaslStart, [&](auto session) { - auto request = auth::SaslStartCommand::parse( - IDLParserErrorContext("speculative saslStart"), cmdObj); + auto request = + auth::SaslStartCommand::parse(IDLParserContext("speculative saslStart"), cmdObj); auto reply = auth::runSaslStart(opCtx, session, request); result->append(auth::kSpeculativeAuthenticate, reply.toBSON()); }); diff --git a/src/mongo/db/catalog/index_build_entry_test.cpp b/src/mongo/db/catalog/index_build_entry_test.cpp index 0bac70f981b..7ac4206c0d7 100644 --- a/src/mongo/db/catalog/index_build_entry_test.cpp +++ b/src/mongo/db/catalog/index_build_entry_test.cpp @@ -126,7 +126,7 @@ TEST(IndexBuildEntryTest, SerializeAndDeserialize) { BSONObj obj = entry.toBSON(); ASSERT_TRUE(obj.valid()); - IDLParserErrorContext ctx("IndexBuildsEntry Parser"); + IDLParserContext ctx("IndexBuildsEntry Parser"); IndexBuildEntry rebuiltEntry = IndexBuildEntry::parse(ctx, obj); checkIfEqual(entry, rebuiltEntry); diff --git a/src/mongo/db/change_stream_options_manager.cpp b/src/mongo/db/change_stream_options_manager.cpp index d99b3352c95..816ec7f53da 100644 --- a/src/mongo/db/change_stream_options_manager.cpp +++ b/src/mongo/db/change_stream_options_manager.cpp @@ -87,7 +87,7 @@ Status ChangeStreamOptionsParameter::set(const BSONElement& newValueElement) { ChangeStreamOptionsManager& changeStreamOptionsManager = ChangeStreamOptionsManager::get(getGlobalServiceContext()); ChangeStreamOptions newOptions = ChangeStreamOptions::parse( - IDLParserErrorContext("changeStreamOptions"), newValueElement.Obj()); + IDLParserContext("changeStreamOptions"), newValueElement.Obj()); return changeStreamOptionsManager .setOptions(Client::getCurrent()->getOperationContext(), newOptions) @@ -106,7 +106,7 @@ Status ChangeStreamOptionsParameter::validate(const BSONElement& newValueElement // default- initialized to 'off'. This is useful for parameter initialization at startup but // causes the IDL parser to not enforce the presence of `expireAfterSeconds` in BSON // representations. We assert that and the existence of PreAndPostImages here. - IDLParserErrorContext ctxt = IDLParserErrorContext("changeStreamOptions"_sd); + IDLParserContext ctxt = IDLParserContext("changeStreamOptions"_sd); if (auto preAndPostImagesObj = changeStreamOptionsObj["preAndPostImages"_sd]; !preAndPostImagesObj.eoo()) { if (preAndPostImagesObj["expireAfterSeconds"_sd].eoo()) { diff --git a/src/mongo/db/change_stream_pre_images_collection_manager.cpp b/src/mongo/db/change_stream_pre_images_collection_manager.cpp index d7d8bbfe955..afae70d7da4 100644 --- a/src/mongo/db/change_stream_pre_images_collection_manager.cpp +++ b/src/mongo/db/change_stream_pre_images_collection_manager.cpp @@ -264,7 +264,7 @@ public: } auto preImage = - ChangeStreamPreImage::parse(IDLParserErrorContext("pre-image"), preImageObj); + ChangeStreamPreImage::parse(IDLParserContext("pre-image"), preImageObj); return {{std::move(preImage.getId().getNsUUID()), std::move(preImage.getId().getTs()), std::move(preImage.getOperationTime())}}; diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 3c8c915c023..89556f1e57f 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -347,8 +347,7 @@ bool CommandHelpers::appendCommandStatusNoThrow(BSONObjBuilder& result, const St // construct an invalid error reply. if (!status.isOK() && getTestCommandsEnabled()) { try { - ErrorReply::parse(IDLParserErrorContext("appendCommandStatusNoThrow"), - result.asTempObj()); + ErrorReply::parse(IDLParserContext("appendCommandStatusNoThrow"), result.asTempObj()); } catch (const DBException&) { invariant(false, "invalid error-response to a command constructed in " diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 778b34db424..317f82915ac 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -1044,7 +1044,7 @@ constexpr StringData command_alias_v = CommandAlias<T>::kAlias; * * - a static member factory function 'parse', callable as: * - * const IDLParserErrorContext& idlCtx = ...; + * const IDLParserContext& idlCtx = ...; * const OpMsgRequest& opMsgRequest = ...; * Request r = Request::parse(idlCtx, opMsgRequest); * @@ -1106,7 +1106,7 @@ protected: * Calls to this function should be done only in test mode so that we don't expose users to * errors if we construct an invalid error reply. */ - static bool checkIsErrorStatus(const BSONObj& resultObj, const IDLParserErrorContext& ctx) { + static bool checkIsErrorStatus(const BSONObj& resultObj, const IDLParserContext& ctx) { auto wcStatus = getWriteConcernStatusFromCommandResult(resultObj); if (!wcStatus.isOK()) { if (wcStatus.code() == ErrorCodes::TypeMismatch) { @@ -1119,7 +1119,7 @@ protected: auto status = getStatusFromCommandResult(resultObj); if (!status.isOK()) { // Will throw if the result doesn't match the ErrorReply. - ErrorReply::parse(IDLParserErrorContext("ErrorType", &ctx), resultObj); + ErrorReply::parse(IDLParserContext("ErrorType", &ctx), resultObj); return true; } } @@ -1146,8 +1146,8 @@ private: const BSONObj& cmdObj) { // TODO SERVER-67155 pass tenantId to the BSONObj parse function return RequestType::parse( - IDLParserErrorContext(RequestType::kCommandName, - APIParameters::get(opCtx).getAPIStrict().value_or(false)), + IDLParserContext(RequestType::kCommandName, + APIParameters::get(opCtx).getAPIStrict().value_or(false)), cmdObj); } @@ -1184,7 +1184,7 @@ class ErrmsgCommandDeprecated : public BasicCommand { * * - a static member factory function 'parse', callable as: * - * const IDLParserErrorContext& idlCtx = ...; + * const IDLParserContext& idlCtx = ...; * const OpMsgRequest& opMsgRequest = ...; * Request r = Request::parse(idlCtx, opMsgRequest); * @@ -1257,8 +1257,7 @@ private: << command->getName() << "' instead"); } - return RequestType::parse(IDLParserErrorContext(command->getName(), apiStrict), - opMsgRequest); + return RequestType::parse(IDLParserContext(command->getName(), apiStrict), opMsgRequest); } RequestType _request; diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp index e6746101ff2..00c19674764 100644 --- a/src/mongo/db/commands/authentication_commands.cpp +++ b/src/mongo/db/commands/authentication_commands.cpp @@ -444,8 +444,8 @@ void doSpeculativeAuthenticate(OperationContext* opCtx, cmd.append(AuthenticateCommand::kDbNameFieldName, kExternalDB); } - auto authCmdObj = AuthenticateCommand::parse( - IDLParserErrorContext("speculative X509 Authenticate"), cmd.obj()); + auto authCmdObj = + AuthenticateCommand::parse(IDLParserContext("speculative X509 Authenticate"), cmd.obj()); AuthenticationSession::doStep( opCtx, AuthenticationSession::StepType::kSpeculativeAuthenticate, [&](auto session) { diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp index 4c653cbe98e..201904a10a8 100644 --- a/src/mongo/db/commands/count_cmd.cpp +++ b/src/mongo/db/commands/count_cmd.cpp @@ -156,7 +156,7 @@ public: CountCommandRequest request(NamespaceStringOrUUID(NamespaceString{})); try { - request = CountCommandRequest::parse(IDLParserErrorContext("count"), opMsgRequest); + request = CountCommandRequest::parse(IDLParserContext("count"), opMsgRequest); } catch (...) { return exceptionToStatus(); } @@ -238,7 +238,7 @@ public: CurOpFailpointHelpers::waitWhileFailPointEnabled( &hangBeforeCollectionCount, opCtx, "hangBeforeCollectionCount", []() {}, nss); - auto request = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj); + auto request = CountCommandRequest::parse(IDLParserContext("count"), cmdObj); if (shouldDoFLERewrite(request)) { processFLECountD(opCtx, nss, &request); } diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp index 99970945e21..11530897b6b 100644 --- a/src/mongo/db/commands/dbcheck.cpp +++ b/src/mongo/db/commands/dbcheck.cpp @@ -253,11 +253,11 @@ std::unique_ptr<DbCheckRun> getRun(OperationContext* opCtx, // If the dbCheck argument is a string, this is the per-collection form. if (toParse["dbCheck"].type() == BSONType::String) { return singleCollectionRun( - opCtx, dbName, DbCheckSingleInvocation::parse(IDLParserErrorContext(""), toParse)); + opCtx, dbName, DbCheckSingleInvocation::parse(IDLParserContext(""), toParse)); } else { // Otherwise, it's the database-wide form. return fullDatabaseRun( - opCtx, dbName, DbCheckAllInvocation::parse(IDLParserErrorContext(""), toParse)); + opCtx, dbName, DbCheckAllInvocation::parse(IDLParserContext(""), toParse)); } } diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index ab19c34d789..4fc2b2b0f34 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -499,7 +499,7 @@ public: } result.append("ns", nss.ns()); - auto spec = StorageStatsSpec::parse(IDLParserErrorContext("collStats"), jsobj); + auto spec = StorageStatsSpec::parse(IDLParserContext("collStats"), jsobj); Status status = appendCollectionStorageStats(opCtx, nss, spec, &result); if (!status.isOK() && status.code() != ErrorCodes::NamespaceNotFound) { errmsg = status.reason(); @@ -595,7 +595,7 @@ public: } void validateResult(const BSONObj& resultObj) final { - auto reply = Reply::parse(IDLParserErrorContext("CollModReply"), resultObj); + auto reply = Reply::parse(IDLParserContext("CollModReply"), resultObj); coll_mod_reply_validation::validateReply(reply); } diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp index 34f3965d454..e80f4432772 100644 --- a/src/mongo/db/commands/explain_cmd.cpp +++ b/src/mongo/db/commands/explain_cmd.cpp @@ -155,8 +155,8 @@ std::unique_ptr<CommandInvocation> CmdExplain::parse(OperationContext* opCtx, // To enforce API versioning auto cmdObj = ExplainCommandRequest::parse( - IDLParserErrorContext(ExplainCommandRequest::kCommandName, - APIParameters::get(opCtx).getAPIStrict().value_or(false)), + IDLParserContext(ExplainCommandRequest::kCommandName, + APIParameters::get(opCtx).getAPIStrict().value_or(false)), request.body); std::string dbname = cmdObj.getDbName().toString(); ExplainOptions::Verbosity verbosity = cmdObj.getVerbosity(); diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index d06f305eb58..0961660ded5 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -278,7 +278,7 @@ void FeatureCompatibilityVersion::validateSetFeatureCompatibilityVersionRequest( auto fcvObj = findFeatureCompatibilityVersionDocument(opCtx); auto fcvDoc = FeatureCompatibilityVersionDocument::parse( - IDLParserErrorContext("featureCompatibilityVersionDocument"), fcvObj.get()); + IDLParserContext("featureCompatibilityVersionDocument"), fcvObj.get()); auto previousTimestamp = fcvDoc.getChangeTimestamp(); if (setFCVPhase == SetFCVPhaseEnum::kStart) { diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_parser.cpp index abbaed591dd..3e19a5413da 100644 --- a/src/mongo/db/commands/feature_compatibility_version_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_parser.cpp @@ -100,8 +100,7 @@ StatusWith<multiversion::FeatureCompatibilityVersion> FeatureCompatibilityVersio const BSONObj& featureCompatibilityVersionDoc) { try { auto fcvDoc = FeatureCompatibilityVersionDocument::parse( - IDLParserErrorContext("FeatureCompatibilityVersionParser"), - featureCompatibilityVersionDoc); + IDLParserContext("FeatureCompatibilityVersionParser"), featureCompatibilityVersionDoc); auto version = fcvDoc.getVersion(); auto targetVersion = fcvDoc.getTargetVersion(); auto previousVersion = fcvDoc.getPreviousVersion(); diff --git a/src/mongo/db/commands/fle_compact_test.cpp b/src/mongo/db/commands/fle_compact_test.cpp index 26153aadcc8..080b443722c 100644 --- a/src/mongo/db/commands/fle_compact_test.cpp +++ b/src/mongo/db/commands/fle_compact_test.cpp @@ -411,7 +411,7 @@ void FleCompactTest::doSingleDelete(int id, BSONObj encryptedFieldsObj) { auto doc = EncryptionInformationHelpers::encryptionInformationSerializeForDelete( _namespaces.edcNss, efc, &_keyVault); - auto ei = EncryptionInformation::parse(IDLParserErrorContext("test"), doc); + auto ei = EncryptionInformation::parse(IDLParserContext("test"), doc); write_ops::DeleteOpEntry entry; entry.setQ(BSON("_id" << id)); diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index fa71299887c..c6b9154aeec 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -96,7 +96,7 @@ class EchoCommand final : public TypedCommand<EchoCommand> { public: struct Request { static constexpr auto kCommandName = "echo"_sd; - static Request parse(const IDLParserErrorContext&, const OpMsgRequest& request) { + static Request parse(const IDLParserContext&, const OpMsgRequest& request) { return Request{request}; } diff --git a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp index 552b51b4080..044e56c12c4 100644 --- a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp +++ b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp @@ -91,7 +91,7 @@ public: const std::string& db, const BSONObj& cmdObj, BSONObjBuilder& result) override { - IDLParserErrorContext ctx("KillAllSessionsByPatternCmd"); + IDLParserContext ctx("KillAllSessionsByPatternCmd"); auto ksc = KillAllSessionsByPatternCmd::parse(ctx, cmdObj); // The empty command kills all diff --git a/src/mongo/db/commands/kill_all_sessions_command.cpp b/src/mongo/db/commands/kill_all_sessions_command.cpp index e1520f39f36..c9c344b2252 100644 --- a/src/mongo/db/commands/kill_all_sessions_command.cpp +++ b/src/mongo/db/commands/kill_all_sessions_command.cpp @@ -91,7 +91,7 @@ public: const std::string& db, const BSONObj& cmdObj, BSONObjBuilder& result) override { - IDLParserErrorContext ctx("KillAllSessionsCmd"); + IDLParserContext ctx("KillAllSessionsCmd"); auto ksc = KillAllSessionsCmd::parse(ctx, cmdObj); KillAllSessionsByPatternSet patterns; diff --git a/src/mongo/db/commands/kill_sessions_command.cpp b/src/mongo/db/commands/kill_sessions_command.cpp index 298446164f9..410b636f901 100644 --- a/src/mongo/db/commands/kill_sessions_command.cpp +++ b/src/mongo/db/commands/kill_sessions_command.cpp @@ -111,7 +111,7 @@ public: const std::string& db, const BSONObj& cmdObj, BSONObjBuilder& result) override { - IDLParserErrorContext ctx("KillSessionsCmd"); + IDLParserContext ctx("KillSessionsCmd"); auto ksc = KillSessionsCmdFromClient::parse(ctx, cmdObj); KillAllSessionsByPatternSet patterns; diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp index c8cb9d3a77a..9eda8b75894 100644 --- a/src/mongo/db/commands/list_collections.cpp +++ b/src/mongo/db/commands/list_collections.cpp @@ -520,7 +520,7 @@ public: try { firstBatch.push_back(ListCollectionsReplyItem::parse( - IDLParserErrorContext("ListCollectionsReplyItem"), nextDoc)); + IDLParserContext("ListCollectionsReplyItem"), nextDoc)); } catch (const DBException& exc) { LOGV2_ERROR( 5254300, diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index 8281615d664..94ebd846c71 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -326,7 +326,7 @@ public: try { firstBatch.push_back(ListIndexesReplyItem::parse( - IDLParserErrorContext("ListIndexesReplyItem"), nextDoc)); + IDLParserContext("ListIndexesReplyItem"), nextDoc)); } catch (const DBException& exc) { LOGV2_ERROR(5254500, "Could not parse catalog entry while replying to listIndexes", diff --git a/src/mongo/db/commands/map_reduce_agg.cpp b/src/mongo/db/commands/map_reduce_agg.cpp index 6a726a5469c..7d5de91cc91 100644 --- a/src/mongo/db/commands/map_reduce_agg.cpp +++ b/src/mongo/db/commands/map_reduce_agg.cpp @@ -139,7 +139,7 @@ bool runAggregationMapReduce(OperationContext* opCtx, Timer cmdTimer; - auto parsedMr = MapReduceCommandRequest::parse(IDLParserErrorContext("mapReduce"), cmd); + auto parsedMr = MapReduceCommandRequest::parse(IDLParserContext("mapReduce"), cmd); auto expCtx = makeExpressionContext(opCtx, parsedMr, verbosity); auto runnablePipeline = [&]() { auto pipeline = map_reduce_common::translateFromMR(parsedMr, expCtx); diff --git a/src/mongo/db/commands/map_reduce_parse_test.cpp b/src/mongo/db/commands/map_reduce_parse_test.cpp index f89040dbf2e..5201d7c18ad 100644 --- a/src/mongo/db/commands/map_reduce_parse_test.cpp +++ b/src/mongo/db/commands/map_reduce_parse_test.cpp @@ -48,7 +48,7 @@ constexpr auto reduceJavascript = "reduce!"_sd; constexpr auto finalizeJavascript = "finalize!"_sd; TEST(MapReduceParseTest, failedParse) { - auto ctx = IDLParserErrorContext("mapReduce"); + auto ctx = IDLParserContext("mapReduce"); // Missing fields. ASSERT_THROWS(MapReduceCommandRequest::parse(ctx, BSON("" @@ -91,7 +91,7 @@ TEST(MapReduceParseTest, failedParse) { } TEST(MapReduceParseTest, failsToParseCodeWithScope) { - auto ctx = IDLParserErrorContext("mapReduce"); + auto ctx = IDLParserContext("mapReduce"); ASSERT_THROWS(MapReduceCommandRequest::parse(ctx, BSON("mapReduce" @@ -112,7 +112,7 @@ TEST(MapReduceParseTest, failsToParseCodeWithScope) { } TEST(MapReduceParseTest, parseOutputTypes) { - auto ctx = IDLParserErrorContext("mapReduce"); + auto ctx = IDLParserContext("mapReduce"); MapReduceCommandRequest::parse(ctx, BSON("mapReduce" @@ -164,7 +164,7 @@ TEST(MapReduceParseTest, parseOutputTypes) { } TEST(MapReduceParseTest, parseAllOptionalFields) { - auto ctx = IDLParserErrorContext("mapReduce"); + auto ctx = IDLParserContext("mapReduce"); MapReduceCommandRequest::parse(ctx, BSON("mapReduce" @@ -186,7 +186,7 @@ TEST(MapReduceParseTest, parseAllOptionalFields) { } TEST(MapReduceParseTest, deprecatedOptions) { - auto ctx = IDLParserErrorContext("mapReduce"); + auto ctx = IDLParserContext("mapReduce"); // jsMode can be true or false MapReduceCommandRequest::parse(ctx, BSON("mapReduce" diff --git a/src/mongo/db/commands/profile_common.cpp b/src/mongo/db/commands/profile_common.cpp index 8a2daba0298..c9f06aef56b 100644 --- a/src/mongo/db/commands/profile_common.cpp +++ b/src/mongo/db/commands/profile_common.cpp @@ -49,7 +49,7 @@ Status ProfileCmdBase::checkAuthForCommand(Client* client, const BSONObj& cmdObj) const { AuthorizationSession* authzSession = AuthorizationSession::get(client); - auto request = ProfileCmdRequest::parse(IDLParserErrorContext("profile"), cmdObj); + auto request = ProfileCmdRequest::parse(IDLParserContext("profile"), cmdObj); const auto profilingLevel = request.getCommandParameter(); if (profilingLevel < 0 && !request.getSlowms() && !request.getSampleRate()) { @@ -71,7 +71,7 @@ bool ProfileCmdBase::run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { - auto request = ProfileCmdRequest::parse(IDLParserErrorContext("profile"), cmdObj); + auto request = ProfileCmdRequest::parse(IDLParserContext("profile"), cmdObj); const auto profilingLevel = request.getCommandParameter(); // Validate arguments before making changes. diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp index 8cf7aa7abf8..f7876b7690a 100644 --- a/src/mongo/db/commands/rename_collection_cmd.cpp +++ b/src/mongo/db/commands/rename_collection_cmd.cpp @@ -95,7 +95,7 @@ public: string& errmsg, BSONObjBuilder& result) { auto renameRequest = - RenameCollectionCommand::parse(IDLParserErrorContext("renameCollection"), cmdObj); + RenameCollectionCommand::parse(IDLParserContext("renameCollection"), cmdObj); const auto& fromNss = renameRequest.getCommandParameter(); const auto& toNss = renameRequest.getTo(); diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp index 9fa15b7943c..8a834ec2af0 100644 --- a/src/mongo/db/commands/resize_oplog.cpp +++ b/src/mongo/db/commands/resize_oplog.cpp @@ -87,7 +87,7 @@ public: uassert(ErrorCodes::IllegalOperation, "oplog isn't capped", coll->isCapped()); auto params = - ReplSetResizeOplogRequest::parse(IDLParserErrorContext("replSetResizeOplog"), jsobj); + ReplSetResizeOplogRequest::parse(IDLParserContext("replSetResizeOplog"), jsobj); return writeConflictRetry(opCtx, "replSetResizeOplog", coll->ns().ns(), [&] { WriteUnitOfWork wunit(opCtx); diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index f7ed910e167..59310fdf720 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -267,7 +267,7 @@ public: Lock::ExclusiveLock setFCVCommandLock(opCtx->lockState(), commandMutex); auto request = SetFeatureCompatibilityVersion::parse( - IDLParserErrorContext("setFeatureCompatibilityVersion"), cmdObj); + IDLParserContext("setFeatureCompatibilityVersion"), cmdObj); const auto requestedVersion = request.getCommandParameter(); const auto actualVersion = serverGlobalParams.featureCompatibility.getVersion(); if (request.getDowngradeOnDiskChanges()) { @@ -302,7 +302,7 @@ public: auto fcvObj = FeatureCompatibilityVersion::findFeatureCompatibilityVersionDocument(opCtx); auto fcvDoc = FeatureCompatibilityVersionDocument::parse( - IDLParserErrorContext("featureCompatibilityVersionDocument"), fcvObj.get()); + IDLParserContext("featureCompatibilityVersionDocument"), fcvObj.get()); changeTimestamp = fcvDoc.getChangeTimestamp(); uassert(5722800, "The 'changeTimestamp' field is missing in the FCV document persisted by " diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index 70b868a5cda..fb96d4bbd7b 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -803,7 +803,7 @@ public: Status commit() { auto fp = umcTransaction.scoped(); if (fp.isActive()) { - IDLParserErrorContext ctx("umcTransaction"); + IDLParserContext ctx("umcTransaction"); auto delay = UMCTransactionFailPoint::parse(ctx, fp.getData()).getCommitDelayMS(); LOGV2(4993100, "Sleeping prior to committing UMC transaction", diff --git a/src/mongo/db/explain_test.cpp b/src/mongo/db/explain_test.cpp index 866574f0fc5..5c54a439b6d 100644 --- a/src/mongo/db/explain_test.cpp +++ b/src/mongo/db/explain_test.cpp @@ -61,29 +61,29 @@ TEST(ExplainTest, ExplainSerializeToBSONCorrectly) { TEST(ExplainTest, CanParseExplainVerbosity) { auto verbosity = ExplainCommandRequest::parse( - IDLParserErrorContext("explain"), + IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 'queryPlanner', $db: 'dummy'}")) .getVerbosity(); ASSERT(verbosity == Verbosity::kQueryPlanner); verbosity = ExplainCommandRequest::parse( - IDLParserErrorContext("explain"), + IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 'executionStats', $db: 'dummy'}")) .getVerbosity(); ASSERT(verbosity == Verbosity::kExecStats); verbosity = ExplainCommandRequest::parse( - IDLParserErrorContext("explain"), + IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 'allPlansExecution', $db: 'dummy'}")) .getVerbosity(); ASSERT(verbosity == Verbosity::kExecAllPlans); } TEST(ExplainTest, ParsingFailsIfVerbosityIsNotAString) { - ASSERT_THROWS_CODE(ExplainCommandRequest::parse(IDLParserErrorContext("explain"), + ASSERT_THROWS_CODE(ExplainCommandRequest::parse(IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 1}")), DBException, ErrorCodes::TypeMismatch); ASSERT_THROWS_CODE( - ExplainCommandRequest::parse(IDLParserErrorContext("explain"), + ExplainCommandRequest::parse(IDLParserContext("explain"), fromjson("{explain: {}, verbosity: {foo: 'bar'}}")), DBException, ErrorCodes::TypeMismatch); @@ -91,7 +91,7 @@ TEST(ExplainTest, ParsingFailsIfVerbosityIsNotAString) { TEST(ExplainTest, ParsingFailsIfVerbosityStringIsNotRecognized) { ASSERT_THROWS_CODE( - ExplainCommandRequest::parse(IDLParserErrorContext("explain"), + ExplainCommandRequest::parse(IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 'badVerbosity'}")), DBException, ErrorCodes::BadValue); @@ -99,7 +99,7 @@ TEST(ExplainTest, ParsingFailsIfVerbosityStringIsNotRecognized) { TEST(ExplainTest, ParsingFailsIfFirstElementIsNotAnObject) { ASSERT_THROWS_CODE( - ExplainCommandRequest::parse(IDLParserErrorContext("explain"), + ExplainCommandRequest::parse(IDLParserContext("explain"), fromjson("{explain: 1, verbosity: 'queryPlanner'}")), DBException, 40414); @@ -108,7 +108,7 @@ TEST(ExplainTest, ParsingFailsIfFirstElementIsNotAnObject) { TEST(ExplainTest, ParsingFailsIfUnknownFieldInCommandObject) { ASSERT_THROWS_CODE( ExplainCommandRequest::parse( - IDLParserErrorContext("explain"), + IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 'queryPlanner', unknownField: true}")), DBException, 40415); @@ -116,7 +116,7 @@ TEST(ExplainTest, ParsingFailsIfUnknownFieldInCommandObject) { TEST(ExplainTest, CanParseGenericCommandArguments) { ExplainCommandRequest::parse( - IDLParserErrorContext("explain"), + IDLParserContext("explain"), fromjson("{explain: {}, verbosity: 'queryPlanner', comment: true, $db: 'test'}")); } diff --git a/src/mongo/db/fle_crud.cpp b/src/mongo/db/fle_crud.cpp index 38cc9cd5510..0277b0c649f 100644 --- a/src/mongo/db/fle_crud.cpp +++ b/src/mongo/db/fle_crud.cpp @@ -306,7 +306,7 @@ write_ops::DeleteCommandReply processDelete(OperationContext* opCtx, auto ownedRequest = deleteRequest.serialize({}); auto ownedDeleteRequest = - write_ops::DeleteCommandRequest::parse(IDLParserErrorContext("delete"), ownedRequest); + write_ops::DeleteCommandRequest::parse(IDLParserContext("delete"), ownedRequest); auto ownedDeleteOpEntry = ownedDeleteRequest.getDeletes()[0]; auto expCtx = makeExpCtx(opCtx, ownedDeleteRequest, ownedDeleteOpEntry); @@ -394,7 +394,7 @@ write_ops::UpdateCommandReply processUpdate(OperationContext* opCtx, auto ownedRequest = updateRequest.serialize({}); auto ownedUpdateRequest = - write_ops::UpdateCommandRequest::parse(IDLParserErrorContext("update"), ownedRequest); + write_ops::UpdateCommandRequest::parse(IDLParserContext("update"), ownedRequest); auto ownedUpdateOpEntry = ownedUpdateRequest.getUpdates()[0]; auto expCtx = makeExpCtx(opCtx, ownedUpdateRequest, ownedUpdateOpEntry); @@ -674,7 +674,7 @@ StatusWith<std::pair<ReplyType, OpMsgRequest>> processFindAndModifyRequest( auto ownedRequest = findAndModifyRequest.serialize({}); auto ownedFindAndModifyRequest = write_ops::FindAndModifyCommandRequest::parse( - IDLParserErrorContext("findAndModify"), ownedRequest); + IDLParserContext("findAndModify"), ownedRequest); auto expCtx = makeExpCtx(opCtx, ownedFindAndModifyRequest, ownedFindAndModifyRequest); auto findAndModifyBlock = std::make_tuple(ownedFindAndModifyRequest, expCtx); @@ -1208,8 +1208,8 @@ FLEBatchResult processFLEFindAndModify(OperationContext* opCtx, BSONObjBuilder& result) { // There is no findAndModify parsing in mongos so we need to first parse to decide if it is for // FLE2 - auto request = write_ops::FindAndModifyCommandRequest::parse( - IDLParserErrorContext("findAndModify"), cmdObj); + auto request = + write_ops::FindAndModifyCommandRequest::parse(IDLParserContext("findAndModify"), cmdObj); if (!request.getEncryptionInformation().has_value()) { return FLEBatchResult::kNotProcessed; @@ -1359,7 +1359,7 @@ std::pair<write_ops::DeleteCommandReply, BSONObj> FLEQueryInterfaceImpl::deleteW deleteReply.getWriteCommandReplyBase().setWriteErrors(singleStatusToWriteErrors(status)); } else { auto reply = - write_ops::FindAndModifyCommandReply::parse(IDLParserErrorContext("reply"), response); + write_ops::FindAndModifyCommandReply::parse(IDLParserContext("reply"), response); if (reply.getLastErrorObject().getNumDocs() > 0) { deleteReply.getWriteCommandReplyBase().setN(1); @@ -1403,8 +1403,7 @@ std::pair<write_ops::UpdateCommandReply, BSONObj> FLEQueryInterfaceImpl::updateW auto status = getStatusFromWriteCommandReply(response); uassertStatusOK(status); - auto reply = - write_ops::FindAndModifyCommandReply::parse(IDLParserErrorContext("reply"), response); + auto reply = write_ops::FindAndModifyCommandReply::parse(IDLParserContext("reply"), response); write_ops::UpdateCommandReply updateReply; @@ -1474,7 +1473,7 @@ write_ops::FindAndModifyCommandReply FLEQueryInterfaceImpl::findAndModify( auto status = getStatusFromWriteCommandReply(response); uassertStatusOK(status); - return write_ops::FindAndModifyCommandReply::parse(IDLParserErrorContext("reply"), response); + return write_ops::FindAndModifyCommandReply::parse(IDLParserContext("reply"), response); } std::vector<BSONObj> FLEQueryInterfaceImpl::findDocuments(const NamespaceString& nss, diff --git a/src/mongo/db/fle_crud_test.cpp b/src/mongo/db/fle_crud_test.cpp index 0e6489981e8..4b277d60833 100644 --- a/src/mongo/db/fle_crud_test.cpp +++ b/src/mongo/db/fle_crud_test.cpp @@ -385,7 +385,7 @@ EncryptedFieldConfig getTestEncryptedFieldConfig() { ] })"; - return EncryptedFieldConfig::parse(IDLParserErrorContext("root"), fromjson(schema)); + return EncryptedFieldConfig::parse(IDLParserContext("root"), fromjson(schema)); } void FleCrudTest::assertDocumentCounts(uint64_t edc, uint64_t esc, uint64_t ecc, uint64_t ecoc) { @@ -547,7 +547,7 @@ void FleCrudTest::doSingleUpdateWithUpdateDoc(int id, auto efc = getTestEncryptedFieldConfig(); auto doc = EncryptionInformationHelpers::encryptionInformationSerializeForDelete( _edcNs, efc, &_keyVault); - auto ei = EncryptionInformation::parse(IDLParserErrorContext("test"), doc); + auto ei = EncryptionInformation::parse(IDLParserContext("test"), doc); write_ops::UpdateOpEntry entry; entry.setQ(BSON("_id" << id)); @@ -574,7 +574,7 @@ void FleCrudTest::doSingleDelete(int id) { auto doc = EncryptionInformationHelpers::encryptionInformationSerializeForDelete( _edcNs, efc, &_keyVault); - auto ei = EncryptionInformation::parse(IDLParserErrorContext("test"), doc); + auto ei = EncryptionInformation::parse(IDLParserContext("test"), doc); write_ops::DeleteOpEntry entry; entry.setQ(BSON("_id" << id)); @@ -598,7 +598,7 @@ void FleCrudTest::doFindAndModify(write_ops::FindAndModifyCommandRequest& reques auto efc = getTestEncryptedFieldConfig(); auto doc = EncryptionInformationHelpers::encryptionInformationSerializeForDelete( _edcNs, efc, &_keyVault); - auto ei = EncryptionInformation::parse(IDLParserErrorContext("test"), doc); + auto ei = EncryptionInformation::parse(IDLParserContext("test"), doc); request.setEncryptionInformation(ei); @@ -1186,7 +1186,7 @@ TEST_F(FleTagsTest, InsertAndUpdate) { } TEST_F(FleTagsTest, ContentionFactor) { - auto efc = EncryptedFieldConfig::parse(IDLParserErrorContext("root"), fromjson(R"({ + auto efc = EncryptedFieldConfig::parse(IDLParserContext("root"), fromjson(R"({ "escCollection": "esc", "eccCollection": "ecc", "ecocCollection": "ecoc", diff --git a/src/mongo/db/free_mon/free_mon_commands.cpp b/src/mongo/db/free_mon/free_mon_commands.cpp index 78cc3f3a420..d3e28b13a3f 100644 --- a/src/mongo/db/free_mon/free_mon_commands.cpp +++ b/src/mongo/db/free_mon/free_mon_commands.cpp @@ -80,7 +80,7 @@ public: const BSONObj& cmdObj, BSONObjBuilder& result) final { // Command has no members, invoke the parser to confirm that. - IDLParserErrorContext ctx("getFreeMonitoringStatus"); + IDLParserContext ctx("getFreeMonitoringStatus"); GetFreeMonitoringStatus::parse(ctx, cmdObj); if (globalFreeMonParams.freeMonitoringState == EnableCloudStateEnum::kOff) { @@ -135,7 +135,7 @@ public: const std::string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) final { - IDLParserErrorContext ctx("setFreeMonitoring"); + IDLParserContext ctx("setFreeMonitoring"); auto cmd = SetFreeMonitoring::parse(ctx, cmdObj); auto* controller = FreeMonController::get(opCtx->getServiceContext()); diff --git a/src/mongo/db/free_mon/free_mon_commands_stub.cpp b/src/mongo/db/free_mon/free_mon_commands_stub.cpp index 4b8494e5eea..0cde267410d 100644 --- a/src/mongo/db/free_mon/free_mon_commands_stub.cpp +++ b/src/mongo/db/free_mon/free_mon_commands_stub.cpp @@ -78,7 +78,7 @@ public: const BSONObj& cmdObj, BSONObjBuilder& result) final { // Command has no members, invoke the parser to confirm that. - IDLParserErrorContext ctx("getFreeMonitoringStatus"); + IDLParserContext ctx("getFreeMonitoringStatus"); GetFreeMonitoringStatus::parse(ctx, cmdObj); result.append("state", "disabled"); diff --git a/src/mongo/db/free_mon/free_mon_controller_test.cpp b/src/mongo/db/free_mon/free_mon_controller_test.cpp index 50a8b604ee1..c5cd4a76d68 100644 --- a/src/mongo/db/free_mon/free_mon_controller_test.cpp +++ b/src/mongo/db/free_mon/free_mon_controller_test.cpp @@ -582,7 +582,7 @@ TEST(FreeMonRetryTest, TestMetrics) { // Positive: Ensure the response is validated correctly TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { ASSERT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -593,7 +593,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // max reporting interval ASSERT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -604,7 +604,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Positive: version 2 ASSERT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 2LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -615,7 +615,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Positive: empty registration id string ASSERT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "" << "informationalURL" @@ -626,7 +626,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: bad protocol version ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 42LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -637,7 +637,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: halt uploading ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << true << "id" << "mock123" << "informationalURL" @@ -648,7 +648,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: large registartation id ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << std::string(5000, 'a') << "informationalURL" << "http://www.example.com/123" @@ -658,7 +658,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: large URL ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" << std::string(5000, 'b') << "message" @@ -667,7 +667,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: large message ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -676,7 +676,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: too small a reporting interval ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -687,7 +687,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Negative: too large a reporting interval ASSERT_NOT_OK(FreeMonProcessor::validateRegistrationResponse(FreeMonRegistrationResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "id" << "mock123" << "informationalURL" @@ -701,7 +701,7 @@ TEST(FreeMonProcessorTest, TestRegistrationResponseValidation) { // Positive: Ensure the response is validated correctly TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { ASSERT_OK(FreeMonProcessor::validateMetricsResponse( - FreeMonMetricsResponse::parse(IDLParserErrorContext("foo"), + FreeMonMetricsResponse::parse(IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" @@ -714,7 +714,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Positive: Support version 2 ASSERT_OK(FreeMonProcessor::validateMetricsResponse( - FreeMonMetricsResponse::parse(IDLParserErrorContext("foo"), + FreeMonMetricsResponse::parse(IDLParserContext("foo"), BSON("version" << 2LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" @@ -727,7 +727,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Positive: Add resendRegistration ASSERT_OK(FreeMonProcessor::validateMetricsResponse(FreeMonMetricsResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 2LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" @@ -741,7 +741,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Positive: max reporting interval ASSERT_OK(FreeMonProcessor::validateMetricsResponse(FreeMonMetricsResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" @@ -754,7 +754,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: bad protocol version ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse( - FreeMonMetricsResponse::parse(IDLParserErrorContext("foo"), + FreeMonMetricsResponse::parse(IDLParserContext("foo"), BSON("version" << 42LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" << "mock123" @@ -766,7 +766,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: halt uploading ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse( - FreeMonMetricsResponse::parse(IDLParserErrorContext("foo"), + FreeMonMetricsResponse::parse(IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << true << "permanentlyDelete" << false << "id" << "mock123" @@ -778,7 +778,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: large registartation id ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse(FreeMonMetricsResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" << std::string(5000, 'a') << "informationalURL" << "http://www.example.com/123" @@ -788,7 +788,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: large URL ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse(FreeMonMetricsResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" @@ -799,7 +799,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: large message ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse(FreeMonMetricsResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" << "mock123" @@ -809,7 +809,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: too small a reporting interval ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse( - FreeMonMetricsResponse::parse(IDLParserErrorContext("foo"), + FreeMonMetricsResponse::parse(IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" << "mock123" @@ -821,7 +821,7 @@ TEST(FreeMonProcessorTest, TestMetricsResponseValidation) { // Negative: too large a reporting interval ASSERT_NOT_OK(FreeMonProcessor::validateMetricsResponse(FreeMonMetricsResponse::parse( - IDLParserErrorContext("foo"), + IDLParserContext("foo"), BSON("version" << 1LL << "haltMetricsUploading" << false << "permanentlyDelete" << false << "id" << "mock123" diff --git a/src/mongo/db/free_mon/free_mon_mongod.cpp b/src/mongo/db/free_mon/free_mon_mongod.cpp index 9e52bd45446..6e1bc93d77d 100644 --- a/src/mongo/db/free_mon/free_mon_mongod.cpp +++ b/src/mongo/db/free_mon/free_mon_mongod.cpp @@ -114,8 +114,7 @@ public: ConstDataRange cdr(blobData.get(), blobSize); BSONObj respObj = cdr.read<Validated<BSONObj>>(); - auto resp = - FreeMonRegistrationResponse::parse(IDLParserErrorContext("response"), respObj); + auto resp = FreeMonRegistrationResponse::parse(IDLParserContext("response"), respObj); return resp; }); @@ -137,7 +136,7 @@ public: BSONObj respObj = cdr.read<Validated<BSONObj>>(); - auto resp = FreeMonMetricsResponse::parse(IDLParserErrorContext("response"), respObj); + auto resp = FreeMonMetricsResponse::parse(IDLParserContext("response"), respObj); return resp; }); diff --git a/src/mongo/db/free_mon/free_mon_processor.cpp b/src/mongo/db/free_mon/free_mon_processor.cpp index 247e1c131a8..b230d9431cc 100644 --- a/src/mongo/db/free_mon/free_mon_processor.cpp +++ b/src/mongo/db/free_mon/free_mon_processor.cpp @@ -966,7 +966,7 @@ void FreeMonProcessor::doNotifyOnUpsert( Client* client, const FreeMonMessageWithPayload<FreeMonMessageType::NotifyOnUpsert>* msg) { try { const BSONObj& doc = msg->getPayload(); - auto newState = FreeMonStorageState::parse(IDLParserErrorContext("free_mon_storage"), doc); + auto newState = FreeMonStorageState::parse(IDLParserContext("free_mon_storage"), doc); // Likely, the update changed something if (newState != _state) { diff --git a/src/mongo/db/free_mon/free_mon_storage.cpp b/src/mongo/db/free_mon/free_mon_storage.cpp index 89be39295e1..5d20eee1e23 100644 --- a/src/mongo/db/free_mon/free_mon_storage.cpp +++ b/src/mongo/db/free_mon/free_mon_storage.cpp @@ -74,7 +74,7 @@ boost::optional<FreeMonStorageState> FreeMonStorage::read(OperationContext* opCt uassertStatusOK(swObj.getStatus()); } - return FreeMonStorageState::parse(IDLParserErrorContext("FreeMonStorage"), swObj.getValue()); + return FreeMonStorageState::parse(IDLParserContext("FreeMonStorage"), swObj.getValue()); } void FreeMonStorage::replace(OperationContext* opCtx, const FreeMonStorageState& doc) { diff --git a/src/mongo/db/free_mon/free_mon_storage_test.cpp b/src/mongo/db/free_mon/free_mon_storage_test.cpp index bdd6db0bf52..97369228f6d 100644 --- a/src/mongo/db/free_mon/free_mon_storage_test.cpp +++ b/src/mongo/db/free_mon/free_mon_storage_test.cpp @@ -121,7 +121,7 @@ TEST_F(FreeMonStorageTest, TestStorage) { FreeMonStorageState initialState = - FreeMonStorageState::parse(IDLParserErrorContext("foo"), + FreeMonStorageState::parse(IDLParserContext("foo"), BSON("version" << 1LL << "state" << "enabled" << "registrationId" @@ -172,7 +172,7 @@ TEST_F(FreeMonStorageTest, TestSecondary) { FreeMonStorageState initialState = - FreeMonStorageState::parse(IDLParserErrorContext("foo"), + FreeMonStorageState::parse(IDLParserContext("foo"), BSON("version" << 1LL << "state" << "enabled" << "registrationId" @@ -198,7 +198,7 @@ TEST_F(FreeMonStorageTest, TestSecondary) { ASSERT_OK(_getReplCoord()->setFollowerMode(repl::MemberState::RS_SECONDARY)); FreeMonStorageState updatedState = - FreeMonStorageState::parse(IDLParserErrorContext("foo"), + FreeMonStorageState::parse(IDLParserContext("foo"), BSON("version" << 2LL << "state" << "enabled" << "registrationId" diff --git a/src/mongo/db/index_build_entry_helpers.cpp b/src/mongo/db/index_build_entry_helpers.cpp index 4d6f0884a89..901c37a98f5 100644 --- a/src/mongo/db/index_build_entry_helpers.cpp +++ b/src/mongo/db/index_build_entry_helpers.cpp @@ -311,7 +311,7 @@ StatusWith<IndexBuildEntry> getIndexBuildEntry(OperationContext* opCtx, UUID ind } try { - IDLParserErrorContext ctx("IndexBuildsEntry Parser"); + IDLParserContext ctx("IndexBuildsEntry Parser"); IndexBuildEntry indexBuildEntry = IndexBuildEntry::parse(ctx, obj); return indexBuildEntry; } catch (DBException& ex) { diff --git a/src/mongo/db/keys_collection_client_direct.cpp b/src/mongo/db/keys_collection_client_direct.cpp index 1879765beb7..a03a7cf3c16 100644 --- a/src/mongo/db/keys_collection_client_direct.cpp +++ b/src/mongo/db/keys_collection_client_direct.cpp @@ -129,7 +129,7 @@ StatusWith<std::vector<KeyDocumentType>> KeysCollectionClientDirect::_getNewKeys for (auto&& keyDoc : keyDocs) { KeyDocumentType key; try { - key = KeyDocumentType::parse(IDLParserErrorContext("keyDoc"), keyDoc); + key = KeyDocumentType::parse(IDLParserContext("keyDoc"), keyDoc); } catch (...) { return exceptionToStatus(); } diff --git a/src/mongo/db/keys_collection_document_test.cpp b/src/mongo/db/keys_collection_document_test.cpp index ff8a2fd57b7..84e03868584 100644 --- a/src/mongo/db/keys_collection_document_test.cpp +++ b/src/mongo/db/keys_collection_document_test.cpp @@ -54,7 +54,7 @@ TEST(KeysCollectionDocument, Roundtrip) { keysCollectionDoc.setKeysCollectionDocumentBase({purpose, key, expiresAt}); auto serializedObj = keysCollectionDoc.toBSON(); - auto parsedKey = KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), serializedObj); + auto parsedKey = KeysCollectionDocument::parse(IDLParserContext("keyDoc"), serializedObj); ASSERT_EQ(keyId, parsedKey.getKeyId()); ASSERT_EQ(purpose, parsedKey.getPurpose()); @@ -77,10 +77,9 @@ TEST(KeysCollectionDocument, MissingKeyIdShouldFailToParse) { expiresAt.asTimestamp().append(builder.bb(), "expiresAt"); auto serializedObj = builder.done(); - ASSERT_THROWS_CODE( - KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), serializedObj), - AssertionException, - 40414); + ASSERT_THROWS_CODE(KeysCollectionDocument::parse(IDLParserContext("keyDoc"), serializedObj), + AssertionException, + 40414); } TEST(KeysCollectionDocument, MissingPurposeShouldFailToParse) { @@ -98,10 +97,9 @@ TEST(KeysCollectionDocument, MissingPurposeShouldFailToParse) { expiresAt.asTimestamp().append(builder.bb(), "expiresAt"); auto serializedObj = builder.done(); - ASSERT_THROWS_CODE( - KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), serializedObj), - AssertionException, - 40414); + ASSERT_THROWS_CODE(KeysCollectionDocument::parse(IDLParserContext("keyDoc"), serializedObj), + AssertionException, + 40414); } TEST(KeysCollectionDocument, MissingKeyShouldFailToParse) { @@ -117,10 +115,9 @@ TEST(KeysCollectionDocument, MissingKeyShouldFailToParse) { expiresAt.asTimestamp().append(builder.bb(), "expiresAt"); auto serializedObj = builder.done(); - ASSERT_THROWS_CODE( - KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), serializedObj), - AssertionException, - 40414); + ASSERT_THROWS_CODE(KeysCollectionDocument::parse(IDLParserContext("keyDoc"), serializedObj), + AssertionException, + 40414); } TEST(KeysCollectionDocument, MissingExpiresAtShouldFailToParse) { @@ -138,10 +135,9 @@ TEST(KeysCollectionDocument, MissingExpiresAtShouldFailToParse) { builder.append("key", BSONBinData(key.data(), key.size(), BinDataGeneral)); auto serializedObj = builder.done(); - ASSERT_THROWS_CODE( - KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), serializedObj), - AssertionException, - 40414); + ASSERT_THROWS_CODE(KeysCollectionDocument::parse(IDLParserContext("keyDoc"), serializedObj), + AssertionException, + 40414); } } // namespace diff --git a/src/mongo/db/matcher/expression_type.h b/src/mongo/db/matcher/expression_type.h index c81aade1701..6bdd8073736 100644 --- a/src/mongo/db/matcher/expression_type.h +++ b/src/mongo/db/matcher/expression_type.h @@ -339,8 +339,7 @@ public: if (static_cast<size_t>(binDataLen) < sizeof(FleBlobHeader)) return false; - auto fleBlobSubType = - EncryptedBinDataType_parse(IDLParserErrorContext("subtype"), binData[0]); + auto fleBlobSubType = EncryptedBinDataType_parse(IDLParserContext("subtype"), binData[0]); switch (fleBlobSubType) { case EncryptedBinDataType::kDeterministic: case EncryptedBinDataType::kRandom: { diff --git a/src/mongo/db/matcher/schema/encrypt_schema_types_test.cpp b/src/mongo/db/matcher/schema/encrypt_schema_types_test.cpp index 1eb0d6ee6a8..211c894d4b6 100644 --- a/src/mongo/db/matcher/schema/encrypt_schema_types_test.cpp +++ b/src/mongo/db/matcher/schema/encrypt_schema_types_test.cpp @@ -97,7 +97,7 @@ TEST(EncryptSchemaTest, ParseFullEncryptObjectFromBSON) { << "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" << "keyId" << "/pointer"); - IDLParserErrorContext ctxt("encrypt"); + IDLParserContext ctxt("encrypt"); auto encryptInfo = EncryptionInfo::parse(ctxt, encryptInfoBSON); MatcherTypeSet resultMatcherSet; resultMatcherSet.bsonTypes.insert(BSONType::NumberInt); @@ -110,7 +110,7 @@ TEST(EncryptSchemaTest, ParseFullEncryptObjectFromBSON) { TEST(EncryptSchemaTest, WrongTypeFailsParse) { BSONObj encryptInfoBSON = BSON("keyId" << 2); - IDLParserErrorContext ctxt("encrypt"); + IDLParserContext ctxt("encrypt"); ASSERT_THROWS_CODE(EncryptionInfo::parse(ctxt, encryptInfoBSON), DBException, 51085); encryptInfoBSON = BSON("algorithm" << "garbage"); diff --git a/src/mongo/db/matcher/schema/json_schema_parser.cpp b/src/mongo/db/matcher/schema/json_schema_parser.cpp index 7b664daac63..3db0391051b 100644 --- a/src/mongo/db/matcher/schema/json_schema_parser.cpp +++ b/src/mongo/db/matcher/schema/json_schema_parser.cpp @@ -1585,7 +1585,7 @@ Status translateEncryptionKeywords(StringMap<BSONElement>& keywordMap, << "' cannot be an empty object "}; } - const IDLParserErrorContext ctxt("encryptMetadata"); + const IDLParserContext ctxt("encryptMetadata"); try { // Discard the result as we are only concerned with validation. EncryptionMetadata::parse(ctxt, encryptMetadataElt.embeddedObject()); @@ -1604,7 +1604,7 @@ Status translateEncryptionKeywords(StringMap<BSONElement>& keywordMap, try { // This checks the types of all the fields. Will throw on any parsing error. - const IDLParserErrorContext encryptCtxt("encrypt"); + const IDLParserContext encryptCtxt("encrypt"); auto encryptInfo = EncryptionInfo::parse(encryptCtxt, encryptElt.embeddedObject()); auto infoType = encryptInfo.getBsonType(); diff --git a/src/mongo/db/mirror_maestro.cpp b/src/mongo/db/mirror_maestro.cpp index f1b2358c97d..e3bf69e9831 100644 --- a/src/mongo/db/mirror_maestro.cpp +++ b/src/mongo/db/mirror_maestro.cpp @@ -242,7 +242,7 @@ public: } gMirroredReadsSection; auto parseMirroredReadsParameters(const BSONObj& obj) { - IDLParserErrorContext ctx("mirrorReads"); + IDLParserContext ctx("mirrorReads"); return MirroredReadsParameters::parse(ctx, obj); } diff --git a/src/mongo/db/op_observer/op_observer_impl.cpp b/src/mongo/db/op_observer/op_observer_impl.cpp index 1c87f872769..b4a48472b8c 100644 --- a/src/mongo/db/op_observer/op_observer_impl.cpp +++ b/src/mongo/db/op_observer/op_observer_impl.cpp @@ -681,8 +681,8 @@ void OpObserverImpl::onInserts(OperationContext* opCtx, } } else if (nss == NamespaceString::kExternalKeysCollectionNamespace) { for (auto it = first; it != last; it++) { - auto externalKey = ExternalKeysCollectionDocument::parse( - IDLParserErrorContext("externalKey"), it->doc); + auto externalKey = + ExternalKeysCollectionDocument::parse(IDLParserContext("externalKey"), it->doc); opCtx->recoveryUnit()->onCommit( [this, opCtx, externalKey = std::move(externalKey)]( boost::optional<Timestamp> unusedCommitTime) mutable { diff --git a/src/mongo/db/op_observer/op_observer_impl_test.cpp b/src/mongo/db/op_observer/op_observer_impl_test.cpp index 5d56f716d19..e9d4b02b946 100644 --- a/src/mongo/db/op_observer/op_observer_impl_test.cpp +++ b/src/mongo/db/op_observer/op_observer_impl_test.cpp @@ -293,7 +293,7 @@ protected: AutoGetCollection sideCollection( opCtx, NamespaceString::kConfigImagesNamespace, LockMode::MODE_IS); return repl::ImageEntry::parse( - IDLParserErrorContext("image entry"), + IDLParserContext("image entry"), Helpers::findOneForTesting( opCtx, sideCollection.getCollection(), BSON("_id" << sessionId.toBSON()))); } @@ -303,7 +303,7 @@ protected: opCtx, NamespaceString::kSessionTransactionsTableNamespace, LockMode::MODE_IS); return SessionTxnRecord::parse( - IDLParserErrorContext("txn record"), + IDLParserContext("txn record"), Helpers::findOneForTesting( opCtx, configTransactions.getCollection(), BSON("_id" << sessionId.toBSON()))); } @@ -323,7 +323,7 @@ protected: preImagesCollection.getCollection(), BSON("_id" << preImageId.toBSON())) .getOwned(); - return ChangeStreamPreImage::parse(IDLParserErrorContext("pre-image"), *container); + return ChangeStreamPreImage::parse(IDLParserContext("pre-image"), *container); } ReadWriteConcernDefaultsLookupMock _lookupMock; @@ -1197,7 +1197,7 @@ protected: auto txnRecordObj = cursor->next(); auto txnRecord = - SessionTxnRecord::parse(IDLParserErrorContext("SessionEntryWritten"), txnRecordObj); + SessionTxnRecord::parse(IDLParserContext("SessionEntryWritten"), txnRecordObj); ASSERT(!cursor->more()); ASSERT_EQ(session()->getSessionId(), txnRecord.getSessionId()); ASSERT_EQ(txnNum, txnRecord.getTxnNum()); @@ -1233,7 +1233,7 @@ protected: auto txnRecordObj = cursor->next(); auto txnRecord = - SessionTxnRecord::parse(IDLParserErrorContext("SessionEntryWritten"), txnRecordObj); + SessionTxnRecord::parse(IDLParserContext("SessionEntryWritten"), txnRecordObj); ASSERT(!cursor->more()); ASSERT_EQ(session()->getSessionId(), txnRecord.getSessionId()); if (!startOpTime) { diff --git a/src/mongo/db/op_observer/user_write_block_mode_op_observer.cpp b/src/mongo/db/op_observer/user_write_block_mode_op_observer.cpp index 0a3b49055ea..941072f2230 100644 --- a/src/mongo/db/op_observer/user_write_block_mode_op_observer.cpp +++ b/src/mongo/db/op_observer/user_write_block_mode_op_observer.cpp @@ -63,7 +63,7 @@ void UserWriteBlockModeOpObserver::onInserts(OperationContext* opCtx, const auto& insertedDoc = it->doc; const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("UserWriteBlockOpObserver"), insertedDoc); + IDLParserContext("UserWriteBlockOpObserver"), insertedDoc); opCtx->recoveryUnit()->onCommit( [opCtx, blockShardedDDL = collCSDoc.getBlockNewUserShardedDDL(), @@ -96,7 +96,7 @@ void UserWriteBlockModeOpObserver::onUpdate(OperationContext* opCtx, if (args.nss == NamespaceString::kUserWritesCriticalSectionsNamespace && !user_writes_recoverable_critical_section_util::inRecoveryMode(opCtx)) { const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("UserWriteBlockOpObserver"), args.updateArgs->updatedDoc); + IDLParserContext("UserWriteBlockOpObserver"), args.updateArgs->updatedDoc); opCtx->recoveryUnit()->onCommit( [opCtx, @@ -150,7 +150,7 @@ void UserWriteBlockModeOpObserver::onDelete(OperationContext* opCtx, const auto& deletedDoc = documentId; const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("UserWriteBlockOpObserver"), deletedDoc); + IDLParserContext("UserWriteBlockOpObserver"), deletedDoc); opCtx->recoveryUnit()->onCommit( [opCtx, deletedNss = collCSDoc.getNss()](boost::optional<Timestamp>) { diff --git a/src/mongo/db/ops/write_ops.cpp b/src/mongo/db/ops/write_ops.cpp index 4389f1b0032..0ef8f329558 100644 --- a/src/mongo/db/ops/write_ops.cpp +++ b/src/mongo/db/ops/write_ops.cpp @@ -311,7 +311,7 @@ BSONObj WriteError::serialize() const { } // namespace write_ops InsertCommandRequest InsertOp::parse(const OpMsgRequest& request) { - auto insertOp = InsertCommandRequest::parse(IDLParserErrorContext("insert"), request); + auto insertOp = InsertCommandRequest::parse(IDLParserContext("insert"), request); validate(insertOp); return insertOp; @@ -346,7 +346,7 @@ InsertCommandRequest InsertOp::parseLegacy(const Message& msgRaw) { InsertCommandReply InsertOp::parseResponse(const BSONObj& obj) { uassertStatusOK(getStatusFromCommandResult(obj)); - return InsertCommandReply::parse(IDLParserErrorContext("insertReply"), obj); + return InsertCommandReply::parse(IDLParserContext("insertReply"), obj); } void InsertOp::validate(const InsertCommandRequest& insertOp) { @@ -355,7 +355,7 @@ void InsertOp::validate(const InsertCommandRequest& insertOp) { } UpdateCommandRequest UpdateOp::parse(const OpMsgRequest& request) { - auto updateOp = UpdateCommandRequest::parse(IDLParserErrorContext("update"), request); + auto updateOp = UpdateCommandRequest::parse(IDLParserContext("update"), request); checkOpCountForCommand(updateOp, updateOp.getUpdates().size()); return updateOp; @@ -364,7 +364,7 @@ UpdateCommandRequest UpdateOp::parse(const OpMsgRequest& request) { UpdateCommandReply UpdateOp::parseResponse(const BSONObj& obj) { uassertStatusOK(getStatusFromCommandResult(obj)); - return UpdateCommandReply::parse(IDLParserErrorContext("updateReply"), obj); + return UpdateCommandReply::parse(IDLParserContext("updateReply"), obj); } void UpdateOp::validate(const UpdateCommandRequest& updateOp) { @@ -374,11 +374,11 @@ void UpdateOp::validate(const UpdateCommandRequest& updateOp) { FindAndModifyCommandReply FindAndModifyOp::parseResponse(const BSONObj& obj) { uassertStatusOK(getStatusFromCommandResult(obj)); - return FindAndModifyCommandReply::parse(IDLParserErrorContext("findAndModifyReply"), obj); + return FindAndModifyCommandReply::parse(IDLParserContext("findAndModifyReply"), obj); } DeleteCommandRequest DeleteOp::parse(const OpMsgRequest& request) { - auto deleteOp = DeleteCommandRequest::parse(IDLParserErrorContext("delete"), request); + auto deleteOp = DeleteCommandRequest::parse(IDLParserContext("delete"), request); checkOpCountForCommand(deleteOp, deleteOp.getDeletes().size()); return deleteOp; @@ -386,7 +386,7 @@ DeleteCommandRequest DeleteOp::parse(const OpMsgRequest& request) { DeleteCommandReply DeleteOp::parseResponse(const BSONObj& obj) { uassertStatusOK(getStatusFromCommandResult(obj)); - return DeleteCommandReply::parse(IDLParserErrorContext("deleteReply"), obj); + return DeleteCommandReply::parse(IDLParserContext("deleteReply"), obj); } void DeleteOp::validate(const DeleteCommandRequest& deleteOp) { diff --git a/src/mongo/db/ops/write_ops_retryability.cpp b/src/mongo/db/ops/write_ops_retryability.cpp index 084bc14d5dc..4f0189e6572 100644 --- a/src/mongo/db/ops/write_ops_retryability.cpp +++ b/src/mongo/db/ops/write_ops_retryability.cpp @@ -144,8 +144,7 @@ BSONObj extractPreOrPostImage(OperationContext* opCtx, const repl::OplogEntry& o << sessionId.toBSON() << " cannot be found"); } - auto entry = - repl::ImageEntry::parse(IDLParserErrorContext("ImageEntryForRequest"), imageDoc); + auto entry = repl::ImageEntry::parse(IDLParserContext("ImageEntryForRequest"), imageDoc); if (entry.getInvalidated()) { // This case is expected when a node could not correctly compute a retry image due // to data inconsistency while in initial sync. diff --git a/src/mongo/db/persistent_task_store.h b/src/mongo/db/persistent_task_store.h index d5ef0e50d49..8b21e9b9c5b 100644 --- a/src/mongo/db/persistent_task_store.h +++ b/src/mongo/db/persistent_task_store.h @@ -158,8 +158,8 @@ public: while (cursor->more()) { auto bson = cursor->next(); - auto t = T::parse( - IDLParserErrorContext("PersistentTaskStore:" + _storageNss.toString()), bson); + auto t = + T::parse(IDLParserContext("PersistentTaskStore:" + _storageNss.toString()), bson); if (bool shouldContinue = handler(t); !shouldContinue) return; diff --git a/src/mongo/db/persistent_task_store_test.cpp b/src/mongo/db/persistent_task_store_test.cpp index c2c2beeb19b..0f711d0bffa 100644 --- a/src/mongo/db/persistent_task_store_test.cpp +++ b/src/mongo/db/persistent_task_store_test.cpp @@ -52,7 +52,7 @@ struct TestTask { min(bson.getField("min").Int()), max(bson.getField("max").Int()) {} - static TestTask parse(IDLParserErrorContext, BSONObj bson) { + static TestTask parse(IDLParserContext, BSONObj bson) { return TestTask{bson}; } diff --git a/src/mongo/db/pipeline/aggregation_request_helper.cpp b/src/mongo/db/pipeline/aggregation_request_helper.cpp index 6a73259bef1..143ae976f0d 100644 --- a/src/mongo/db/pipeline/aggregation_request_helper.cpp +++ b/src/mongo/db/pipeline/aggregation_request_helper.cpp @@ -103,7 +103,7 @@ AggregateCommandRequest parseFromBSON(OperationContext* opCtx, } AggregateCommandRequest request(nss); - request = AggregateCommandRequest::parse(IDLParserErrorContext("aggregate", apiStrict), + request = AggregateCommandRequest::parse(IDLParserContext("aggregate", apiStrict), cmdObjChanged ? cmdObjBob.obj() : cmdObj); if (explainVerbosity) { @@ -285,9 +285,8 @@ mongo::SimpleCursorOptions parseAggregateCursorFromBSON(const BSONElement& curso "cursor field must be missing or an object", cursorElem.type() == mongo::Object); - SimpleCursorOptions cursor = - SimpleCursorOptions::parse(IDLParserErrorContext(AggregateCommandRequest::kCursorFieldName), - cursorElem.embeddedObject()); + SimpleCursorOptions cursor = SimpleCursorOptions::parse( + IDLParserContext(AggregateCommandRequest::kCursorFieldName), cursorElem.embeddedObject()); if (!cursor.getBatchSize()) cursor.setBatchSize(aggregation_request_helper::kDefaultBatchSize); diff --git a/src/mongo/db/pipeline/change_stream_event_transform.cpp b/src/mongo/db/pipeline/change_stream_event_transform.cpp index 5e2cdafaa66..ef2aad694c5 100644 --- a/src/mongo/db/pipeline/change_stream_event_transform.cpp +++ b/src/mongo/db/pipeline/change_stream_event_transform.cpp @@ -59,8 +59,7 @@ Document copyDocExceptFields(const Document& source, const std::set<StringData>& repl::OpTypeEnum getOplogOpType(const Document& oplog) { auto opTypeField = oplog[repl::OplogEntry::kOpTypeFieldName]; checkValueType(opTypeField, repl::OplogEntry::kOpTypeFieldName, BSONType::String); - return repl::OpType_parse(IDLParserErrorContext("ChangeStreamEntry.op"), - opTypeField.getString()); + return repl::OpType_parse(IDLParserContext("ChangeStreamEntry.op"), opTypeField.getString()); } Value makeChangeStreamNsField(const NamespaceString& nss) { diff --git a/src/mongo/db/pipeline/document_source_change_stream.cpp b/src/mongo/db/pipeline/document_source_change_stream.cpp index 82caea4c82c..2c56f29d45b 100644 --- a/src/mongo/db/pipeline/document_source_change_stream.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream.cpp @@ -276,7 +276,7 @@ list<intrusive_ptr<DocumentSource>> DocumentSourceChangeStream::createFromBson( "$changeStream stage expects a document as argument", elem.type() == BSONType::Object); - auto spec = DocumentSourceChangeStreamSpec::parse(IDLParserErrorContext("$changeStream"), + auto spec = DocumentSourceChangeStreamSpec::parse(IDLParserContext("$changeStream"), elem.embeddedObject()); // Make sure that it is legal to run this $changeStream before proceeding. diff --git a/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp b/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp index 756bf9b8219..f7dcf3da213 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp @@ -70,7 +70,7 @@ DocumentSourceChangeStreamAddPostImage::createFromBson( str::stream() << "the '" << kStageName << "' stage spec must be an object", elem.type() == BSONType::Object); auto parsedSpec = DocumentSourceChangeStreamAddPostImageSpec::parse( - IDLParserErrorContext("DocumentSourceChangeStreamAddPostImageSpec"), elem.Obj()); + IDLParserContext("DocumentSourceChangeStreamAddPostImageSpec"), elem.Obj()); return new DocumentSourceChangeStreamAddPostImage(expCtx, parsedSpec.getFullDocument()); } diff --git a/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp b/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp index aca01dda4d3..dc087c22e3f 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp @@ -69,7 +69,7 @@ DocumentSourceChangeStreamAddPreImage::createFromBson( str::stream() << "the '" << kStageName << "' stage spec must be an object", elem.type() == BSONType::Object); auto parsedSpec = DocumentSourceChangeStreamAddPreImageSpec::parse( - IDLParserErrorContext("DocumentSourceChangeStreamAddPreImageSpec"), elem.Obj()); + IDLParserContext("DocumentSourceChangeStreamAddPreImageSpec"), elem.Obj()); return make_intrusive<DocumentSourceChangeStreamAddPreImage>( expCtx, parsedSpec.getFullDocumentBeforeChange()); } diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp b/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp index 4fe0b17094b..0732278536b 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp @@ -86,8 +86,7 @@ DocumentSourceChangeStreamCheckInvalidate::createFromBson( spec.type() == Object); auto parsed = DocumentSourceChangeStreamCheckInvalidateSpec::parse( - IDLParserErrorContext("DocumentSourceChangeStreamCheckInvalidateSpec"), - spec.embeddedObject()); + IDLParserContext("DocumentSourceChangeStreamCheckInvalidateSpec"), spec.embeddedObject()); return new DocumentSourceChangeStreamCheckInvalidate( expCtx, parsed.getStartAfterInvalidate() ? parsed.getStartAfterInvalidate()->getData() diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp b/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp index 3861b21693d..d95ff78f58e 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp @@ -142,8 +142,7 @@ DocumentSourceChangeStreamCheckResumability::createFromBson( spec.type() == Object); auto parsed = DocumentSourceChangeStreamCheckResumabilitySpec::parse( - IDLParserErrorContext("DocumentSourceChangeStreamCheckResumabilitySpec"), - spec.embeddedObject()); + IDLParserContext("DocumentSourceChangeStreamCheckResumabilitySpec"), spec.embeddedObject()); return new DocumentSourceChangeStreamCheckResumability(expCtx, parsed.getResumeToken().getData()); } diff --git a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp index c11cb0a1aeb..efb9cdf9c6c 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp @@ -114,7 +114,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceChangeStreamOplogMatch::creat "the match filter must be an expression in an object", elem.type() == BSONType::Object); auto parsedSpec = DocumentSourceChangeStreamOplogMatchSpec::parse( - IDLParserErrorContext("DocumentSourceChangeStreamOplogMatchSpec"), elem.Obj()); + IDLParserContext("DocumentSourceChangeStreamOplogMatchSpec"), elem.Obj()); // Note: raw new used here to access private constructor. return new DocumentSourceChangeStreamOplogMatch(parsedSpec.getFilter(), pExpCtx); diff --git a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp index 914b4d7d359..5d52b8fb0e9 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp @@ -63,8 +63,8 @@ DocumentSourceChangeStreamTransform::createFromBson( uassert(5467601, "the '$_internalChangeStreamTransform' object spec must be an object", rawSpec.type() == BSONType::Object); - auto spec = DocumentSourceChangeStreamSpec::parse(IDLParserErrorContext("$changeStream"), - rawSpec.Obj()); + auto spec = + DocumentSourceChangeStreamSpec::parse(IDLParserContext("$changeStream"), rawSpec.Obj()); return new DocumentSourceChangeStreamTransform(expCtx, std::move(spec)); } diff --git a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp index 899b44b556f..63b0c9735e3 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp @@ -100,7 +100,7 @@ DocumentSourceChangeStreamUnwindTransaction::createFromBson( str::stream() << "the '" << kStageName << "' stage spec must be an object", elem.type() == BSONType::Object); auto parsedSpec = DocumentSourceChangeStreamUnwindTransactionSpec::parse( - IDLParserErrorContext("DocumentSourceChangeStreamUnwindTransactionSpec"), elem.Obj()); + IDLParserContext("DocumentSourceChangeStreamUnwindTransactionSpec"), elem.Obj()); return new DocumentSourceChangeStreamUnwindTransaction(parsedSpec.getFilter(), expCtx); } @@ -209,8 +209,7 @@ DocumentSource::GetNextResult DocumentSourceChangeStreamUnwindTransaction::doGet bool DocumentSourceChangeStreamUnwindTransaction::_isTransactionOplogEntry(const Document& doc) { auto op = doc[repl::OplogEntry::kOpTypeFieldName]; - auto opType = - repl::OpType_parse(IDLParserErrorContext("ChangeStreamEntry.op"), op.getStringData()); + auto opType = repl::OpType_parse(IDLParserContext("ChangeStreamEntry.op"), op.getStringData()); auto commandVal = doc["o"]; if (opType != repl::OpTypeEnum::kCommand || diff --git a/src/mongo/db/pipeline/document_source_coll_stats.cpp b/src/mongo/db/pipeline/document_source_coll_stats.cpp index c00f5fcd44d..19619ed9021 100644 --- a/src/mongo/db/pipeline/document_source_coll_stats.cpp +++ b/src/mongo/db/pipeline/document_source_coll_stats.cpp @@ -65,8 +65,8 @@ intrusive_ptr<DocumentSource> DocumentSourceCollStats::createFromBson( uassert(40166, str::stream() << "$collStats must take a nested object but found: " << specElem, specElem.type() == BSONType::Object); - auto spec = DocumentSourceCollStatsSpec::parse(IDLParserErrorContext(kStageName), - specElem.embeddedObject()); + auto spec = + DocumentSourceCollStatsSpec::parse(IDLParserContext(kStageName), specElem.embeddedObject()); return make_intrusive<DocumentSourceCollStats>(pExpCtx, std::move(spec)); } diff --git a/src/mongo/db/pipeline/document_source_coll_stats.h b/src/mongo/db/pipeline/document_source_coll_stats.h index 72c6923ccdc..f637bd53455 100644 --- a/src/mongo/db/pipeline/document_source_coll_stats.h +++ b/src/mongo/db/pipeline/document_source_coll_stats.h @@ -49,7 +49,7 @@ public: uassert(5447000, str::stream() << "$collStats must take a nested object but found: " << specElem, specElem.type() == BSONType::Object); - auto spec = DocumentSourceCollStatsSpec::parse(IDLParserErrorContext(kStageName), + auto spec = DocumentSourceCollStatsSpec::parse(IDLParserContext(kStageName), specElem.embeddedObject()); return std::make_unique<LiteParsed>(specElem.fieldName(), nss, std::move(spec)); } diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp index 5fca6b613af..d72e17571fe 100644 --- a/src/mongo/db/pipeline/document_source_densify.cpp +++ b/src/mongo/db/pipeline/document_source_densify.cpp @@ -146,7 +146,7 @@ list<intrusive_ptr<DocumentSource>> createFromBsonInternal( << typeName(elem.type()), elem.type() == BSONType::Object); - auto spec = DensifySpec::parse(IDLParserErrorContext(stageName), elem.embeddedObject()); + auto spec = DensifySpec::parse(IDLParserContext(stageName), elem.embeddedObject()); auto rangeStatement = RangeStatement::parse(spec.getRange()); list<FieldPath> partitions; diff --git a/src/mongo/db/pipeline/document_source_exchange_test.cpp b/src/mongo/db/pipeline/document_source_exchange_test.cpp index fe9a50f45f7..58d184a7a46 100644 --- a/src/mongo/db/pipeline/document_source_exchange_test.cpp +++ b/src/mongo/db/pipeline/document_source_exchange_test.cpp @@ -139,7 +139,7 @@ protected: } auto parseSpec(const BSONObj& spec) { - IDLParserErrorContext ctx("internalExchange"); + IDLParserContext ctx("internalExchange"); return ExchangeSpec::parse(ctx, spec); } diff --git a/src/mongo/db/pipeline/document_source_fill.cpp b/src/mongo/db/pipeline/document_source_fill.cpp index 870e719325b..66a061e3576 100644 --- a/src/mongo/db/pipeline/document_source_fill.cpp +++ b/src/mongo/db/pipeline/document_source_fill.cpp @@ -59,7 +59,7 @@ std::list<boost::intrusive_ptr<DocumentSource>> createFromBson( << typeName(elem.type()), elem.type() == BSONType::Object); - auto spec = FillSpec::parse(IDLParserErrorContext(kStageName), elem.embeddedObject()); + auto spec = FillSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); std::list<boost::intrusive_ptr<DocumentSource>> outputPipeline; BSONObjBuilder setWindowFieldsSpec; @@ -81,7 +81,7 @@ std::list<boost::intrusive_ptr<DocumentSource>> createFromBson( "Each fill output specification must be an object with exactly one field", fieldSpec.type() == BSONType::Object); auto parsedSpec = - FillOutputSpec::parse(IDLParserErrorContext(kStageName), fieldSpec.embeddedObject()); + FillOutputSpec::parse(IDLParserContext(kStageName), fieldSpec.embeddedObject()); if (auto&& method = parsedSpec.getMethod()) { uassert(6050201, "Each fill output specification must have exactly one of 'method' or 'value' " diff --git a/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp b/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp index 0aa220b95c0..b94b191f9ff 100644 --- a/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp @@ -83,7 +83,7 @@ boost::optional<repl::OplogEntry> forgeNoopImageOplogEntry( return boost::none; } - auto image = repl::ImageEntry::parse(IDLParserErrorContext("image entry"), imageDoc->toBson()); + auto image = repl::ImageEntry::parse(IDLParserContext("image entry"), imageDoc->toBson()); if (image.getTxnNumber() != oplogEntry.getTxnNumber()) { // In our snapshot, fetch the current transaction number for a session. If that diff --git a/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp b/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp index 4926253cc2e..69a0b5ce4f9 100644 --- a/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp +++ b/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp @@ -59,8 +59,8 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalApplyOplogUpdate::cre << " stage must be an object, but found type: " << typeName(elem.type()), elem.type() == BSONType::Object); - auto spec = InternalApplyOplogUpdateSpec::parse(IDLParserErrorContext(kStageName), - elem.embeddedObject()); + auto spec = + InternalApplyOplogUpdateSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); return new DocumentSourceInternalApplyOplogUpdate(pExpCtx, spec.getOplogUpdate()); } diff --git a/src/mongo/db/pipeline/document_source_list_local_sessions.cpp b/src/mongo/db/pipeline/document_source_list_local_sessions.cpp index 426a8d3bacb..91d57031a02 100644 --- a/src/mongo/db/pipeline/document_source_list_local_sessions.cpp +++ b/src/mongo/db/pipeline/document_source_list_local_sessions.cpp @@ -141,7 +141,7 @@ mongo::ListSessionsSpec mongo::listSessionsParseSpec(StringData stageName, << typeName(spec.type()), spec.type() == BSONType::Object); - IDLParserErrorContext ctx(stageName); + IDLParserContext ctx(stageName); auto ret = ListSessionsSpec::parse(ctx, spec.Obj()); uassert(ErrorCodes::UnsupportedFormat, diff --git a/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp b/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp index f01b449025d..9135e4bd55d 100644 --- a/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp +++ b/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp @@ -179,7 +179,7 @@ TEST_F(DocumentSourceMergeCursorsTest, ShouldBeAbleToParseSerializedARMParams) { // Make sure the serialized version can be parsed into an identical AsyncResultsMergerParams. auto newSpec = serializationArray[0].getDocument().toBson(); ASSERT(newSpec["$mergeCursors"].type() == BSONType::Object); - auto newParams = AsyncResultsMergerParams::parse(IDLParserErrorContext("$mergeCursors test"), + auto newParams = AsyncResultsMergerParams::parse(IDLParserContext("$mergeCursors test"), newSpec["$mergeCursors"].Obj()); ASSERT_TRUE(params.getSort()); ASSERT_BSONOBJ_EQ(*params.getSort(), *newParams.getSort()); diff --git a/src/mongo/db/pipeline/document_source_merge_spec.cpp b/src/mongo/db/pipeline/document_source_merge_spec.cpp index 7f8356435bf..f48de321d72 100644 --- a/src/mongo/db/pipeline/document_source_merge_spec.cpp +++ b/src/mongo/db/pipeline/document_source_merge_spec.cpp @@ -125,7 +125,7 @@ MergeWhenMatchedPolicy mergeWhenMatchedParseFromBSON(const BSONElement& elem) { invariant(elem.type() == BSONType::String); - IDLParserErrorContext ctx{DocumentSourceMergeSpec::kWhenMatchedFieldName}; + IDLParserContext ctx{DocumentSourceMergeSpec::kWhenMatchedFieldName}; auto value = elem.valueStringData(); auto mode = MergeWhenMatchedMode_parse(ctx, value); diff --git a/src/mongo/db/pipeline/document_source_replace_root.cpp b/src/mongo/db/pipeline/document_source_replace_root.cpp index fb4bb2cb951..ee1922c6042 100644 --- a/src/mongo/db/pipeline/document_source_replace_root.cpp +++ b/src/mongo/db/pipeline/document_source_replace_root.cpp @@ -87,8 +87,7 @@ intrusive_ptr<DocumentSource> DocumentSourceReplaceRoot::createFromBson( << " stage, got " << typeName(elem.type()), elem.type() == Object); - auto spec = - ReplaceRootSpec::parse(IDLParserErrorContext(kStageName), elem.embeddedObject()); + auto spec = ReplaceRootSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); // The IDL doesn't give us back the type we need to feed into the expression parser, and // the expression parser needs the extra state in 'vps' and 'expCtx', so for now we have diff --git a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp index 9dc9b77d13d..5e2ea9a91a0 100644 --- a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp +++ b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp @@ -81,8 +81,8 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceSetVariableFromSubPipeline::c << typeName(elem.type()), elem.type() == BSONType::Object); - auto spec = SetVariableFromSubPipelineSpec::parse(IDLParserErrorContext(kStageName), - elem.embeddedObject()); + auto spec = + SetVariableFromSubPipelineSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); const auto searchMetaStr = "$$" + Variables::getBuiltinVariableName(Variables::kSearchMetaId); uassert( 625291, diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp index aaee42b59d0..f21394ae338 100644 --- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp +++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp @@ -93,8 +93,7 @@ list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::createFro << typeName(elem.type()), elem.type() == BSONType::Object); - auto spec = - SetWindowFieldsSpec::parse(IDLParserErrorContext(kStageName), elem.embeddedObject()); + auto spec = SetWindowFieldsSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); auto partitionBy = [&]() -> boost::optional<boost::intrusive_ptr<Expression>> { if (auto partitionBy = spec.getPartitionBy()) return Expression::parseOperand( @@ -330,8 +329,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalSetWindowFields::crea << typeName(elem.type()), elem.type() == BSONType::Object); - auto spec = - SetWindowFieldsSpec::parse(IDLParserErrorContext(kStageName), elem.embeddedObject()); + auto spec = SetWindowFieldsSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); auto partitionBy = [&]() -> boost::optional<boost::intrusive_ptr<Expression>> { if (auto partitionBy = spec.getPartitionBy()) return Expression::parseOperand( diff --git a/src/mongo/db/pipeline/document_source_union_with.cpp b/src/mongo/db/pipeline/document_source_union_with.cpp index e232fe41d75..e8066c7b0dd 100644 --- a/src/mongo/db/pipeline/document_source_union_with.cpp +++ b/src/mongo/db/pipeline/document_source_union_with.cpp @@ -130,7 +130,7 @@ std::unique_ptr<DocumentSourceUnionWith::LiteParsed> DocumentSourceUnionWith::Li unionNss = NamespaceString(nss.dbName(), spec.valueStringData()); } else { auto unionWithSpec = - UnionWithSpec::parse(IDLParserErrorContext(kStageName), spec.embeddedObject()); + UnionWithSpec::parse(IDLParserContext(kStageName), spec.embeddedObject()); if (unionWithSpec.getColl()) { unionNss = NamespaceString(nss.dbName(), *unionWithSpec.getColl()); } else { @@ -188,7 +188,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceUnionWith::createFromBson( unionNss = NamespaceString(expCtx->ns.dbName(), elem.valueStringData()); } else { auto unionWithSpec = - UnionWithSpec::parse(IDLParserErrorContext(kStageName), elem.embeddedObject()); + UnionWithSpec::parse(IDLParserContext(kStageName), elem.embeddedObject()); if (unionWithSpec.getColl()) { unionNss = NamespaceString(expCtx->ns.dbName(), *unionWithSpec.getColl()); } else { diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index 321d1e43eae..5007dacda7f 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -3847,7 +3847,7 @@ intrusive_ptr<Expression> ExpressionInternalFLEEqual::parse(ExpressionContext* c BSONElement expr, const VariablesParseState& vps) { - IDLParserErrorContext ctx(kInternalFleEq); + IDLParserContext ctx(kInternalFleEq); auto fleEq = InternalFleEqStruct::parse(ctx, expr.Obj()); auto fieldExpr = Expression::parseOperand(expCtx, fleEq.getField().getElement(), vps); diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp index 8b8f6e476dd..f9e966c4733 100644 --- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp +++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp @@ -1286,7 +1286,7 @@ partitionCursors(std::vector<OwnedRemoteCursor> ownedCursors) { if (!maybeCursorType) { untypedCursors.push_back(std::move(ownedCursor)); } else { - auto cursorType = CursorType_parse(IDLParserErrorContext("ShardedAggHelperCursorType"), + auto cursorType = CursorType_parse(IDLParserContext("ShardedAggHelperCursorType"), maybeCursorType.get()); if (cursorType == CursorTypeEnum::DocumentResult) { resultsCursors.push_back(std::move(ownedCursor)); diff --git a/src/mongo/db/process_health/health_monitoring_server_parameters.cpp b/src/mongo/db/process_health/health_monitoring_server_parameters.cpp index 52dbf31a1c6..1f1c0a90d11 100644 --- a/src/mongo/db/process_health/health_monitoring_server_parameters.cpp +++ b/src/mongo/db/process_health/health_monitoring_server_parameters.cpp @@ -72,7 +72,7 @@ ConfigValues mergeConfigValues(const ConfigValues& oldValues, const ConfigValues Status HealthMonitoringIntensitiesServerParameter::setFromString(const std::string& value) { const auto oldValue = **_data; auto newValue = HealthObserverIntensities::parse( - IDLParserErrorContext("health monitoring intensities"), fromjson(value)); + IDLParserContext("health monitoring intensities"), fromjson(value)); newValue = mergeConfigValues(oldValue, newValue); **_data = newValue; process_health::FaultManager::healthMonitoringIntensitiesUpdated(oldValue, newValue); @@ -82,7 +82,7 @@ Status HealthMonitoringIntensitiesServerParameter::setFromString(const std::stri Status HealthMonitoringIntensitiesServerParameter::set(const BSONElement& newValueElement) { const auto oldValue = **_data; auto newValue = HealthObserverIntensities::parse( - IDLParserErrorContext("health monitoring intensities"), newValueElement.Obj()); + IDLParserContext("health monitoring intensities"), newValueElement.Obj()); newValue = mergeConfigValues(oldValue, newValue); **_data = newValue; process_health::FaultManager::healthMonitoringIntensitiesUpdated(oldValue, newValue); @@ -99,13 +99,13 @@ void HealthMonitoringIntensitiesServerParameter::append(OperationContext*, Status HealthMonitoringProgressMonitorServerParameter::setFromString(const std::string& value) { *_data = HealthObserverProgressMonitorConfig::parse( - IDLParserErrorContext("health monitoring liveness"), fromjson(value)); + IDLParserContext("health monitoring liveness"), fromjson(value)); return Status::OK(); } Status HealthMonitoringProgressMonitorServerParameter::set(const BSONElement& newValueElement) { *_data = HealthObserverProgressMonitorConfig::parse( - IDLParserErrorContext("health monitoring liveness"), newValueElement.Obj()); + IDLParserContext("health monitoring liveness"), newValueElement.Obj()); return Status::OK(); } @@ -119,8 +119,8 @@ void HealthMonitoringProgressMonitorServerParameter::append(OperationContext*, Status PeriodicHealthCheckIntervalsServerParameter::setFromString(const std::string& value) { const auto oldValue = **_data; - auto newValue = HealthObserverIntervals::parse( - IDLParserErrorContext("health monitoring interval"), fromjson(value)); + auto newValue = HealthObserverIntervals::parse(IDLParserContext("health monitoring interval"), + fromjson(value)); newValue = mergeConfigValues(oldValue, newValue); **_data = newValue; return Status::OK(); @@ -128,8 +128,8 @@ Status PeriodicHealthCheckIntervalsServerParameter::setFromString(const std::str Status PeriodicHealthCheckIntervalsServerParameter::set(const BSONElement& newValueElement) { const auto oldValue = **_data; - auto newValue = HealthObserverIntervals::parse( - IDLParserErrorContext("health monitoring interval"), newValueElement.Obj()); + auto newValue = HealthObserverIntervals::parse(IDLParserContext("health monitoring interval"), + newValueElement.Obj()); newValue = mergeConfigValues(oldValue, newValue); **_data = newValue; return Status::OK(); diff --git a/src/mongo/db/query/count_command_test.cpp b/src/mongo/db/query/count_command_test.cpp index da0326746a3..f5409b0bc80 100644 --- a/src/mongo/db/query/count_command_test.cpp +++ b/src/mongo/db/query/count_command_test.cpp @@ -43,7 +43,7 @@ namespace { static const NamespaceString testns("TestDB.TestColl"); -const IDLParserErrorContext ctxt("count"); +const IDLParserContext ctxt("count"); TEST(CountCommandTest, ParserDealsWithMissingFieldsCorrectly) { auto commandObj = BSON("count" diff --git a/src/mongo/db/query/cursor_request.cpp b/src/mongo/db/query/cursor_request.cpp index 700168f1367..785ac850b35 100644 --- a/src/mongo/db/query/cursor_request.cpp +++ b/src/mongo/db/query/cursor_request.cpp @@ -54,7 +54,7 @@ Status CursorRequest::parseCommandCursorOptions(const BSONObj& cmdObj, BSONObj cursor = cursorElem.embeddedObject(); auto options = - SimpleCursorOptions::parse(IDLParserErrorContext("parseCommandCursorOptions"), cursor); + SimpleCursorOptions::parse(IDLParserContext("parseCommandCursorOptions"), cursor); if (options.getBatchSize()) { *batchSize = *options.getBatchSize(); } diff --git a/src/mongo/db/query/killcursors_request_test.cpp b/src/mongo/db/query/killcursors_request_test.cpp index 692a76831e6..75a248a29ab 100644 --- a/src/mongo/db/query/killcursors_request_test.cpp +++ b/src/mongo/db/query/killcursors_request_test.cpp @@ -38,7 +38,7 @@ namespace mongo { namespace { -const IDLParserErrorContext ctxt("killCursors"); +const IDLParserContext ctxt("killCursors"); TEST(KillCursorsRequestTest, parseSuccess) { auto bsonObj = BSON("killCursors" diff --git a/src/mongo/db/query/parsed_distinct.cpp b/src/mongo/db/query/parsed_distinct.cpp index 8f4afd0408d..b3e3e92a024 100644 --- a/src/mongo/db/query/parsed_distinct.cpp +++ b/src/mongo/db/query/parsed_distinct.cpp @@ -246,7 +246,7 @@ StatusWith<ParsedDistinct> ParsedDistinct::parse(OperationContext* opCtx, const ExtensionsCallback& extensionsCallback, bool isExplain, const CollatorInterface* defaultCollator) { - IDLParserErrorContext ctx("distinct"); + IDLParserContext ctx("distinct"); DistinctCommandRequest parsedDistinct(nss); try { diff --git a/src/mongo/db/query/query_request_helper.cpp b/src/mongo/db/query/query_request_helper.cpp index 370a9a1137e..4a302c92a77 100644 --- a/src/mongo/db/query/query_request_helper.cpp +++ b/src/mongo/db/query/query_request_helper.cpp @@ -154,7 +154,7 @@ std::unique_ptr<FindCommandRequest> makeFromFindCommand(const BSONObj& cmdObj, bool apiStrict) { auto findCommand = std::make_unique<FindCommandRequest>( - FindCommandRequest::parse(IDLParserErrorContext("FindCommandRequest", apiStrict), cmdObj)); + FindCommandRequest::parse(IDLParserContext("FindCommandRequest", apiStrict), cmdObj)); // If there is an explicit namespace specified overwite it. if (nss) { @@ -224,7 +224,7 @@ TailableModeEnum getTailableMode(const FindCommandRequest& findCommand) { void validateCursorResponse(const BSONObj& outputAsBson) { if (getTestCommandsEnabled()) { - CursorInitialReply::parse(IDLParserErrorContext("CursorInitialReply"), outputAsBson); + CursorInitialReply::parse(IDLParserContext("CursorInitialReply"), outputAsBson); } } diff --git a/src/mongo/db/read_write_concern_defaults.cpp b/src/mongo/db/read_write_concern_defaults.cpp index ea912a73581..93b0754f2f3 100644 --- a/src/mongo/db/read_write_concern_defaults.cpp +++ b/src/mongo/db/read_write_concern_defaults.cpp @@ -165,8 +165,7 @@ void ReadWriteConcernDefaults::observeDirectWriteToConfigSettings(OperationConte // no new defaults document and the RWConcern will be default constructed, which matches the // behavior when lookup discovers a non-existent defaults document. auto newDefaultsDoc = newDoc - ? RWConcernDefault::parse(IDLParserErrorContext("RWDefaultsWriteObserver"), - newDoc->getOwned()) + ? RWConcernDefault::parse(IDLParserContext("RWDefaultsWriteObserver"), newDoc->getOwned()) : RWConcernDefault(); opCtx->recoveryUnit()->onCommit([this, opCtx, newDefaultsDoc = std::move(newDefaultsDoc)]( diff --git a/src/mongo/db/read_write_concern_defaults_cache_lookup_mongod.cpp b/src/mongo/db/read_write_concern_defaults_cache_lookup_mongod.cpp index 7eaa64d458a..ff337f50921 100644 --- a/src/mongo/db/read_write_concern_defaults_cache_lookup_mongod.cpp +++ b/src/mongo/db/read_write_concern_defaults_cache_lookup_mongod.cpp @@ -62,9 +62,8 @@ boost::optional<RWConcernDefault> readWriteConcernDefaultsCacheLookupMongoD( // Note that a default constructed RWConcern is returned if no document is found instead of // boost::none. This is to avoid excessive lookups when there is no defaults document, because // otherwise every attempt to get the defaults from the RWC cache would trigger a lookup. - return RWConcernDefault::parse( - IDLParserErrorContext("ReadWriteConcernDefaultsCacheLookupMongoD"), - getPersistedDefaultRWConcernDocument(opCtx)); + return RWConcernDefault::parse(IDLParserContext("ReadWriteConcernDefaultsCacheLookupMongoD"), + getPersistedDefaultRWConcernDocument(opCtx)); } void readWriteConcernDefaultsMongodStartupChecks(OperationContext* opCtx) { diff --git a/src/mongo/db/read_write_concern_provenance.cpp b/src/mongo/db/read_write_concern_provenance.cpp index ff078311629..39a4008a9e5 100644 --- a/src/mongo/db/read_write_concern_provenance.cpp +++ b/src/mongo/db/read_write_concern_provenance.cpp @@ -42,7 +42,7 @@ void ReadWriteConcernProvenance::setSource(boost::optional<Source> source) & { ReadWriteConcernProvenanceBase::setSource(std::move(source)); } -ReadWriteConcernProvenance ReadWriteConcernProvenance::parse(const IDLParserErrorContext& ctxt, +ReadWriteConcernProvenance ReadWriteConcernProvenance::parse(const IDLParserContext& ctxt, const BSONObj& bsonObject) { return ReadWriteConcernProvenance(ReadWriteConcernProvenanceBase::parse(ctxt, bsonObject)); } diff --git a/src/mongo/db/read_write_concern_provenance.h b/src/mongo/db/read_write_concern_provenance.h index 09b8647d88c..72341b9895c 100644 --- a/src/mongo/db/read_write_concern_provenance.h +++ b/src/mongo/db/read_write_concern_provenance.h @@ -144,7 +144,7 @@ public: /** * Creates a provenance with source according to the given object's 'provenance' field. */ - static ReadWriteConcernProvenance parse(const IDLParserErrorContext& ctxt, + static ReadWriteConcernProvenance parse(const IDLParserContext& ctxt, const BSONObj& bsonObject); /** diff --git a/src/mongo/db/read_write_concern_provenance_test.cpp b/src/mongo/db/read_write_concern_provenance_test.cpp index 184dc98dff5..b477f8f825a 100644 --- a/src/mongo/db/read_write_concern_provenance_test.cpp +++ b/src/mongo/db/read_write_concern_provenance_test.cpp @@ -108,34 +108,34 @@ DEATH_TEST(ReadWriteConcernProvenanceTest, TEST(ReadWriteConcernProvenanceTest, ParseAbsentElement) { BSONObj obj = BSON("something" << "else"); - auto provenance = ReadWriteConcernProvenance::parse( - IDLParserErrorContext("ReadWriteConcernProvenanceTest"), obj); + auto provenance = + ReadWriteConcernProvenance::parse(IDLParserContext("ReadWriteConcernProvenanceTest"), obj); ASSERT_FALSE(provenance.hasSource()); } TEST(ReadWriteConcernProvenanceTest, ParseNonString) { BSONObj obj = BSON("provenance" << 42); - ASSERT_THROWS_CODE(ReadWriteConcernProvenance::parse( - IDLParserErrorContext("ReadWriteConcernProvenanceTest"), obj), - DBException, - ErrorCodes::TypeMismatch); + ASSERT_THROWS_CODE( + ReadWriteConcernProvenance::parse(IDLParserContext("ReadWriteConcernProvenanceTest"), obj), + DBException, + ErrorCodes::TypeMismatch); } TEST(ReadWriteConcernProvenanceTest, ParseValidSource) { BSONObj obj = BSON("provenance" << "clientSupplied"); - auto provenance = ReadWriteConcernProvenance::parse( - IDLParserErrorContext("ReadWriteConcernProvenanceTest"), obj); + auto provenance = + ReadWriteConcernProvenance::parse(IDLParserContext("ReadWriteConcernProvenanceTest"), obj); ASSERT_TRUE(ReadWriteConcernProvenance::Source::clientSupplied == provenance.getSource()); } TEST(ReadWriteConcernProvenanceTest, ParseInvalidSource) { BSONObj obj = BSON("provenance" << "foobar"); - ASSERT_THROWS_CODE(ReadWriteConcernProvenance::parse( - IDLParserErrorContext("ReadWriteConcernProvenanceTest"), obj), - DBException, - ErrorCodes::BadValue); + ASSERT_THROWS_CODE( + ReadWriteConcernProvenance::parse(IDLParserContext("ReadWriteConcernProvenanceTest"), obj), + DBException, + ErrorCodes::BadValue); } TEST(ReadWriteConcernProvenanceTest, SerializeUnset) { diff --git a/src/mongo/db/repl/all_database_cloner.cpp b/src/mongo/db/repl/all_database_cloner.cpp index 3088b527fde..3c64becc28c 100644 --- a/src/mongo/db/repl/all_database_cloner.cpp +++ b/src/mongo/db/repl/all_database_cloner.cpp @@ -131,7 +131,7 @@ BaseCloner::AfterStageBehavior AllDatabaseCloner::getInitialSyncIdStage() { "Cannot retrieve sync source initial sync ID", !initialSyncId.isEmpty()); InitialSyncIdDocument initialSyncIdDoc = - InitialSyncIdDocument::parse(IDLParserErrorContext("initialSyncId"), initialSyncId); + InitialSyncIdDocument::parse(IDLParserContext("initialSyncId"), initialSyncId); { stdx::lock_guard<InitialSyncSharedData> lk(*getSharedData()); getSharedData()->setInitialSyncSourceId(lk, initialSyncIdDoc.get_id()); diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp index 47efc80ba9f..8051c52fdd7 100644 --- a/src/mongo/db/repl/apply_ops.cpp +++ b/src/mongo/db/repl/apply_ops.cpp @@ -131,7 +131,7 @@ Status _applyOps(OperationContext* opCtx, // Reject malformed or over-specified operations in an atomic applyOps. try { - ReplOperation::parse(IDLParserErrorContext("applyOps"), opObj); + ReplOperation::parse(IDLParserContext("applyOps"), opObj); } catch (...) { uasserted(ErrorCodes::AtomicityFailure, str::stream() << "cannot apply a malformed or over-specified operation " diff --git a/src/mongo/db/repl/apply_ops_command_info.cpp b/src/mongo/db/repl/apply_ops_command_info.cpp index 7ce6ccf0faf..614d0e7c3c0 100644 --- a/src/mongo/db/repl/apply_ops_command_info.cpp +++ b/src/mongo/db/repl/apply_ops_command_info.cpp @@ -94,7 +94,7 @@ bool ApplyOpsCommandInfo::isAtomic() const { ApplyOpsCommandInfo::ApplyOpsCommandInfo(const BSONObj& applyOpCmd) : _areOpsCrudOnly(_parseAreOpsCrudOnly(applyOpCmd)) { - parseProtected(IDLParserErrorContext("applyOps"), applyOpCmd); + parseProtected(IDLParserContext("applyOps"), applyOpCmd); if (getPreCondition()) { uassert(ErrorCodes::InvalidOptions, @@ -135,7 +135,7 @@ void ApplyOps::extractOperationsTo(const OplogEntry& applyOpsOplogEntry, uint64_t applyOpsIdx{0}; for (const auto& operationDoc : operationDocs) { // Make sure that the inner ops are not malformed or over-specified. - ReplOperation::parse(IDLParserErrorContext("extractOperations"), operationDoc); + ReplOperation::parse(IDLParserContext("extractOperations"), operationDoc); BSONObjBuilder builder(operationDoc); diff --git a/src/mongo/db/repl/database_cloner.cpp b/src/mongo/db/repl/database_cloner.cpp index d280dce1be3..c66e127c430 100644 --- a/src/mongo/db/repl/database_cloner.cpp +++ b/src/mongo/db/repl/database_cloner.cpp @@ -77,7 +77,7 @@ BaseCloner::AfterStageBehavior DatabaseCloner::listCollectionsStage() { ListCollectionResult result; try { result = ListCollectionResult::parse( - IDLParserErrorContext("DatabaseCloner::listCollectionsStage"), info); + IDLParserContext("DatabaseCloner::listCollectionsStage"), info); } catch (const DBException& e) { uasserted( ErrorCodes::FailedToParse, diff --git a/src/mongo/db/repl/dbcheck.cpp b/src/mongo/db/repl/dbcheck.cpp index 25651574898..aa295ce9ca7 100644 --- a/src/mongo/db/repl/dbcheck.cpp +++ b/src/mongo/db/repl/dbcheck.cpp @@ -434,8 +434,8 @@ Status dbCheckOplogCommand(OperationContext* opCtx, if (!opCtx->writesAreReplicated()) { opTime = entry.getOpTime(); } - auto type = OplogEntries_parse(IDLParserErrorContext("type"), cmd.getStringField("type")); - IDLParserErrorContext ctx("o"); + auto type = OplogEntries_parse(IDLParserContext("type"), cmd.getStringField("type")); + IDLParserContext ctx("o"); switch (type) { case OplogEntriesEnum::Batch: { diff --git a/src/mongo/db/repl/election_reason_counter.cpp b/src/mongo/db/repl/election_reason_counter.cpp index 1ca6db64d64..88f20a5c8b8 100644 --- a/src/mongo/db/repl/election_reason_counter.cpp +++ b/src/mongo/db/repl/election_reason_counter.cpp @@ -32,7 +32,7 @@ namespace mongo { namespace repl { -ElectionReasonCounter ElectionReasonCounter::parse(const IDLParserErrorContext& ctxt, +ElectionReasonCounter ElectionReasonCounter::parse(const IDLParserContext& ctxt, const BSONObj& bsonObject) { this->parseProtected(ctxt, bsonObject); return *this; diff --git a/src/mongo/db/repl/election_reason_counter.h b/src/mongo/db/repl/election_reason_counter.h index 89a8dac9b81..bdb9a309fac 100644 --- a/src/mongo/db/repl/election_reason_counter.h +++ b/src/mongo/db/repl/election_reason_counter.h @@ -52,7 +52,7 @@ public: setSuccessful(getSuccessful() + 1); } - ElectionReasonCounter parse(const IDLParserErrorContext& ctxt, const BSONObj& bsonObject); + ElectionReasonCounter parse(const IDLParserContext& ctxt, const BSONObj& bsonObject); }; } // namespace repl diff --git a/src/mongo/db/repl/election_reason_counter_parser.cpp b/src/mongo/db/repl/election_reason_counter_parser.cpp index 4543b828fd1..a4e7fbba318 100644 --- a/src/mongo/db/repl/election_reason_counter_parser.cpp +++ b/src/mongo/db/repl/election_reason_counter_parser.cpp @@ -35,7 +35,7 @@ namespace repl { ElectionReasonCounter parseElectionReasonCounter(const BSONElement& element) { ElectionReasonCounter counter; - IDLParserErrorContext ctxt = IDLParserErrorContext("ElectionReasonCounter"); + IDLParserContext ctxt = IDLParserContext("ElectionReasonCounter"); return counter.parse(ctxt, element.Obj()); } diff --git a/src/mongo/db/repl/initial_sync_base_cloner.cpp b/src/mongo/db/repl/initial_sync_base_cloner.cpp index 0a8c2e9edf5..cf979b02f9e 100644 --- a/src/mongo/db/repl/initial_sync_base_cloner.cpp +++ b/src/mongo/db/repl/initial_sync_base_cloner.cpp @@ -133,7 +133,7 @@ Status InitialSyncBaseCloner::checkInitialSyncIdIsUnchanged() { "Cannot retrieve sync source initial sync ID", !initialSyncId.isEmpty()); InitialSyncIdDocument initialSyncIdDoc = - InitialSyncIdDocument::parse(IDLParserErrorContext("initialSyncId"), initialSyncId); + InitialSyncIdDocument::parse(IDLParserContext("initialSyncId"), initialSyncId); stdx::lock_guard<ReplSyncSharedData> lk(*getSharedData()); uassert(ErrorCodes::InitialSyncFailure, diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 0bbdb31eef9..a25ff3b148f 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -990,8 +990,7 @@ void InitialSyncer::_getBeginFetchingOpTimeCallback( OpTime beginFetchingOpTime = defaultBeginFetchingOpTime; if (docs.size() != 0) { auto entry = SessionTxnRecord::parse( - IDLParserErrorContext("oldest active transaction optime for initial sync"), - docs.front()); + IDLParserContext("oldest active transaction optime for initial sync"), docs.front()); auto optime = entry.getStartOpTime(); if (optime) { beginFetchingOpTime = optime.get(); diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp index 8bfb35d389c..090a71263b4 100644 --- a/src/mongo/db/repl/initial_syncer_test.cpp +++ b/src/mongo/db/repl/initial_syncer_test.cpp @@ -1662,7 +1662,7 @@ TEST_F(InitialSyncerTest, initialSyncer->join(); // OpTimeAndWallTime now uses the IDL parser, so the status code returned is from - // IDLParserErrorContext + // IDLParserContext ASSERT_EQUALS(_lastApplied.getStatus().code(), 40414); } diff --git a/src/mongo/db/repl/member_config.cpp b/src/mongo/db/repl/member_config.cpp index 8a8d954423b..36f682c1b88 100644 --- a/src/mongo/db/repl/member_config.cpp +++ b/src/mongo/db/repl/member_config.cpp @@ -59,7 +59,7 @@ MemberConfig MemberConfig::parseFromBSON(const BSONObj& mcfg) { } MemberConfig::MemberConfig(const BSONObj& mcfg) { - parseProtected(IDLParserErrorContext("MemberConfig"), mcfg); + parseProtected(IDLParserContext("MemberConfig"), mcfg); std::string hostAndPortString = getHost().toString(); boost::trim(hostAndPortString); diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index a8cfa64541d..c3391e63f92 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -952,7 +952,7 @@ const StringMap<ApplyOpMetadata> kOpsMap = { {[](OperationContext* opCtx, const OplogEntry& entry, OplogApplication::Mode mode) -> Status { const auto& cmd = entry.getObject(); auto opMsg = OpMsgRequest::fromDBAndBody(entry.getNss().db(), cmd); - auto collModCmd = CollMod::parse(IDLParserErrorContext("collModOplogEntry"), opMsg); + auto collModCmd = CollMod::parse(IDLParserContext("collModOplogEntry"), opMsg); const auto nssOrUUID([&collModCmd, &entry, mode]() -> NamespaceStringOrUUID { // Oplog entries from secondary oplog application will allways have the Uuid set and // it is only invocations of applyOps directly that may omit it @@ -1040,7 +1040,7 @@ const StringMap<ApplyOpMetadata> kOpsMap = { {"importCollection", {[](OperationContext* opCtx, const OplogEntry& entry, OplogApplication::Mode mode) -> Status { auto importEntry = mongo::ImportCollectionOplogEntry::parse( - IDLParserErrorContext("importCollectionOplogEntry"), entry.getObject()); + IDLParserContext("importCollectionOplogEntry"), entry.getObject()); applyImportCollection(opCtx, importEntry.getImportUUID(), importEntry.getImportCollection(), diff --git a/src/mongo/db/repl/oplog_applier_impl_test.cpp b/src/mongo/db/repl/oplog_applier_impl_test.cpp index ef1767ee934..6d2d9b37d3e 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test.cpp @@ -489,7 +489,7 @@ TEST_F(OplogApplierImplTest, applyOplogEntryToRecordChangeStreamPreImages) { // Verify that the pre-image document is correct. const auto preImageDocument = ChangeStreamPreImage::parse( - IDLParserErrorContext{"test"}, preImageLoadResult.getValue()); + IDLParserContext{"test"}, preImageLoadResult.getValue()); ASSERT_BSONOBJ_EQ(preImageDocument.getPreImage(), document); ASSERT_EQUALS(preImageDocument.getOperationTime(), op.getWallClockTime()) << testDesc; @@ -3167,7 +3167,7 @@ TEST_F(OplogApplierImplTxnTableTest, MultiApplyUpdatesTheTransactionTable) { ASSERT_TRUE(!resultSingleDoc.isEmpty()); auto resultSingle = - SessionTxnRecord::parse(IDLParserErrorContext("resultSingleDoc test"), resultSingleDoc); + SessionTxnRecord::parse(IDLParserContext("resultSingleDoc test"), resultSingleDoc); ASSERT_EQ(resultSingle.getTxnNum(), 5LL); ASSERT_EQ(resultSingle.getLastWriteOpTime(), repl::OpTime(Timestamp(Seconds(1), 0), 1)); @@ -3179,7 +3179,7 @@ TEST_F(OplogApplierImplTxnTableTest, MultiApplyUpdatesTheTransactionTable) { ASSERT_TRUE(!resultDiffTxnDoc.isEmpty()); auto resultDiffTxn = - SessionTxnRecord::parse(IDLParserErrorContext("resultDiffTxnDoc test"), resultDiffTxnDoc); + SessionTxnRecord::parse(IDLParserContext("resultDiffTxnDoc test"), resultDiffTxnDoc); ASSERT_EQ(resultDiffTxn.getTxnNum(), 20LL); ASSERT_EQ(resultDiffTxn.getLastWriteOpTime(), repl::OpTime(Timestamp(Seconds(3), 0), 1)); @@ -3191,7 +3191,7 @@ TEST_F(OplogApplierImplTxnTableTest, MultiApplyUpdatesTheTransactionTable) { ASSERT_TRUE(!resultSameTxnDoc.isEmpty()); auto resultSameTxn = - SessionTxnRecord::parse(IDLParserErrorContext("resultSameTxnDoc test"), resultSameTxnDoc); + SessionTxnRecord::parse(IDLParserContext("resultSameTxnDoc test"), resultSameTxnDoc); ASSERT_EQ(resultSameTxn.getTxnNum(), 30LL); ASSERT_EQ(resultSameTxn.getLastWriteOpTime(), repl::OpTime(Timestamp(Seconds(6), 0), 1)); diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp index 7c3d062a545..d83795d16d5 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp @@ -355,8 +355,7 @@ void checkTxnTable(OperationContext* opCtx, BSON(SessionTxnRecord::kSessionIdFieldName << lsid.toBSON())); ASSERT_FALSE(result.isEmpty()); - auto txnRecord = - SessionTxnRecord::parse(IDLParserErrorContext("parse txn record for test"), result); + auto txnRecord = SessionTxnRecord::parse(IDLParserContext("parse txn record for test"), result); ASSERT_EQ(txnNum, txnRecord.getTxnNum()); ASSERT_EQ(expectedOpTime, txnRecord.getLastWriteOpTime()); diff --git a/src/mongo/db/repl/oplog_entry.cpp b/src/mongo/db/repl/oplog_entry.cpp index 0d1561aa095..60de088b83a 100644 --- a/src/mongo/db/repl/oplog_entry.cpp +++ b/src/mongo/db/repl/oplog_entry.cpp @@ -281,7 +281,7 @@ ReplOperation MutableOplogEntry::makeDeleteOperation(const NamespaceString& nss, StatusWith<MutableOplogEntry> MutableOplogEntry::parse(const BSONObj& object) { try { MutableOplogEntry oplogEntry; - oplogEntry.parseProtected(IDLParserErrorContext("OplogEntryBase"), object); + oplogEntry.parseProtected(IDLParserContext("OplogEntryBase"), object); return oplogEntry; } catch (...) { return exceptionToStatus(); @@ -322,7 +322,7 @@ StatusWith<DurableOplogEntry> DurableOplogEntry::parse(const BSONObj& object) { DurableOplogEntry::DurableOplogEntry(BSONObj rawInput) : _raw(std::move(rawInput)) { _raw = _raw.getOwned(); - parseProtected(IDLParserErrorContext("OplogEntryBase"), _raw); + parseProtected(IDLParserContext("OplogEntryBase"), _raw); // Parse command type from 'o' and 'o2' fields. if (isCommand()) { diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h index 8f10e93f5e9..9e90b15a310 100644 --- a/src/mongo/db/repl/oplog_entry.h +++ b/src/mongo/db/repl/oplog_entry.h @@ -83,7 +83,7 @@ public: kOplog, }; - static ReplOperation parse(const IDLParserErrorContext& ctxt, const BSONObj& bsonObject) { + static ReplOperation parse(const IDLParserContext& ctxt, const BSONObj& bsonObject) { ReplOperation o; o.parseProtected(ctxt, bsonObject); return o; diff --git a/src/mongo/db/repl/oplog_entry_test.cpp b/src/mongo/db/repl/oplog_entry_test.cpp index 4bcc4adfeb0..ca9e20e33b5 100644 --- a/src/mongo/db/repl/oplog_entry_test.cpp +++ b/src/mongo/db/repl/oplog_entry_test.cpp @@ -118,12 +118,12 @@ TEST(OplogEntryTest, OpTimeBaseNonStrictParsing) { // OpTimeBase should be successfully created from an OplogEntry, even though it has // extraneous fields. UNIT_TEST_INTERNALS_IGNORE_UNUSED_RESULT_WARNINGS( - OpTimeBase::parse(IDLParserErrorContext("OpTimeBase"), oplogEntryExtraField)); + OpTimeBase::parse(IDLParserContext("OpTimeBase"), oplogEntryExtraField)); // OplogEntryBase should still use strict parsing and throw an error when it has extraneous // fields. ASSERT_THROWS_CODE( - OplogEntryBase::parse(IDLParserErrorContext("OplogEntryBase"), oplogEntryExtraField), + OplogEntryBase::parse(IDLParserContext("OplogEntryBase"), oplogEntryExtraField), AssertionException, 40415); @@ -135,7 +135,7 @@ TEST(OplogEntryTest, OpTimeBaseNonStrictParsing) { // When an OplogEntryBase is created with a missing required field in a chained struct, it // should throw an exception. ASSERT_THROWS_CODE( - OplogEntryBase::parse(IDLParserErrorContext("OplogEntryBase"), oplogEntryMissingTimestamp), + OplogEntryBase::parse(IDLParserContext("OplogEntryBase"), oplogEntryMissingTimestamp), AssertionException, 40414); } diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index 6a1ffcfc5fc..d4687970b8d 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -903,9 +903,9 @@ Status OplogFetcher::_onSuccessfulBatch(const Documents& documents) { oplogBatchStats.recordMillis(_lastBatchElapsedMS, documents.empty()); if (_cursor->getPostBatchResumeToken()) { - auto pbrt = ResumeTokenOplogTimestamp::parse( - IDLParserErrorContext("OplogFetcher PostBatchResumeToken"), - *_cursor->getPostBatchResumeToken()); + auto pbrt = + ResumeTokenOplogTimestamp::parse(IDLParserContext("OplogFetcher PostBatchResumeToken"), + *_cursor->getPostBatchResumeToken()); info.resumeToken = pbrt.getTs(); } diff --git a/src/mongo/db/repl/optime.cpp b/src/mongo/db/repl/optime.cpp index 30a9b9f3d4f..6dcc821f81b 100644 --- a/src/mongo/db/repl/optime.cpp +++ b/src/mongo/db/repl/optime.cpp @@ -56,7 +56,7 @@ void OpTime::append(BSONObjBuilder* builder, const std::string& subObjName) cons StatusWith<OpTime> OpTime::parseFromOplogEntry(const BSONObj& obj) { try { - OpTimeBase base = OpTimeBase::parse(IDLParserErrorContext("OpTimeBase"), obj); + OpTimeBase base = OpTimeBase::parse(IDLParserContext("OpTimeBase"), obj); long long term = base.getTerm().value_or(kUninitializedTerm); return OpTime(base.getTimestamp(), term); } catch (...) { diff --git a/src/mongo/db/repl/read_concern_args.cpp b/src/mongo/db/repl/read_concern_args.cpp index 1c3508780e4..93ebe67cbd7 100644 --- a/src/mongo/db/repl/read_concern_args.cpp +++ b/src/mongo/db/repl/read_concern_args.cpp @@ -206,7 +206,7 @@ Status ReadConcernArgs::parse(const BSONObj& readConcernObj) { } else if (fieldName == ReadWriteConcernProvenance::kSourceFieldName) { try { _provenance = ReadWriteConcernProvenance::parse( - IDLParserErrorContext("ReadConcernArgs::parse"), readConcernObj); + IDLParserContext("ReadConcernArgs::parse"), readConcernObj); } catch (const DBException&) { return exceptionToStatus(); } diff --git a/src/mongo/db/repl/repl_set_config.cpp b/src/mongo/db/repl/repl_set_config.cpp index a2397b43d0a..46f96bbbb59 100644 --- a/src/mongo/db/repl/repl_set_config.cpp +++ b/src/mongo/db/repl/repl_set_config.cpp @@ -135,7 +135,7 @@ ReplSetConfig::ReplSetConfig(const BSONObj& cfg, // The settings field is optional, but we always serialize it. Because we can't default it in // the IDL, we default it here. setSettings(ReplSetConfigSettings()); - ReplSetConfigBase::parseProtected(IDLParserErrorContext("ReplSetConfig"), cfg); + ReplSetConfigBase::parseProtected(IDLParserContext("ReplSetConfig"), cfg); uassertStatusOK(_initialize(forInitiate, forceTerm, defaultReplicaSetId)); if (cfg.hasField(kRecipientConfigFieldName)) { diff --git a/src/mongo/db/repl/replication_consistency_markers_impl.cpp b/src/mongo/db/repl/replication_consistency_markers_impl.cpp index dbaddbe09cc..f76c8217cf4 100644 --- a/src/mongo/db/repl/replication_consistency_markers_impl.cpp +++ b/src/mongo/db/repl/replication_consistency_markers_impl.cpp @@ -90,7 +90,7 @@ boost::optional<MinValidDocument> ReplicationConsistencyMarkersImpl::_getMinVali } auto minValid = - MinValidDocument::parse(IDLParserErrorContext("MinValidDocument"), result.getValue()); + MinValidDocument::parse(IDLParserContext("MinValidDocument"), result.getValue()); return minValid; } @@ -355,7 +355,7 @@ ReplicationConsistencyMarkersImpl::_getOplogTruncateAfterPointDocument( } auto oplogTruncateAfterPoint = OplogTruncateAfterPointDocument::parse( - IDLParserErrorContext("OplogTruncateAfterPointDocument"), doc.getValue()); + IDLParserContext("OplogTruncateAfterPointDocument"), doc.getValue()); return oplogTruncateAfterPoint; } diff --git a/src/mongo/db/repl/replication_consistency_markers_impl_test.cpp b/src/mongo/db/repl/replication_consistency_markers_impl_test.cpp index 78c23a18f65..be7ea661590 100644 --- a/src/mongo/db/repl/replication_consistency_markers_impl_test.cpp +++ b/src/mongo/db/repl/replication_consistency_markers_impl_test.cpp @@ -255,8 +255,8 @@ TEST_F(ReplicationConsistencyMarkersTest, InitialSyncId) { consistencyMarkers.setInitialSyncIdIfNotSet(opCtx); auto firstInitialSyncIdBson = consistencyMarkers.getInitialSyncId(opCtx); ASSERT_FALSE(firstInitialSyncIdBson.isEmpty()); - InitialSyncIdDocument firstInitialSyncIdDoc = InitialSyncIdDocument::parse( - IDLParserErrorContext("initialSyncId"), firstInitialSyncIdBson); + InitialSyncIdDocument firstInitialSyncIdDoc = + InitialSyncIdDocument::parse(IDLParserContext("initialSyncId"), firstInitialSyncIdBson); // Setting it twice should change nothing. consistencyMarkers.setInitialSyncIdIfNotSet(opCtx); @@ -271,8 +271,8 @@ TEST_F(ReplicationConsistencyMarkersTest, InitialSyncId) { consistencyMarkers.setInitialSyncIdIfNotSet(opCtx); auto secondInitialSyncIdBson = consistencyMarkers.getInitialSyncId(opCtx); ASSERT_FALSE(secondInitialSyncIdBson.isEmpty()); - InitialSyncIdDocument secondInitialSyncIdDoc = InitialSyncIdDocument::parse( - IDLParserErrorContext("initialSyncId"), secondInitialSyncIdBson); + InitialSyncIdDocument secondInitialSyncIdDoc = + InitialSyncIdDocument::parse(IDLParserContext("initialSyncId"), secondInitialSyncIdBson); ASSERT_NE(firstInitialSyncIdDoc.get_id(), secondInitialSyncIdDoc.get_id()); } diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 10ccfa11cdc..20e6e2392a4 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -5173,7 +5173,7 @@ ReadPreference ReplicationCoordinatorImpl::_getSyncSourceReadPreference(WithLock if (!initialSyncSourceReadPreference.empty()) { try { readPreference = - ReadPreference_parse(IDLParserErrorContext("initialSyncSourceReadPreference"), + ReadPreference_parse(IDLParserContext("initialSyncSourceReadPreference"), initialSyncSourceReadPreference); parsedSyncSourceFromInitialSync = true; } catch (const DBException& e) { diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp index 613518af43b..b63f5a704a6 100644 --- a/src/mongo/db/repl/rollback_impl.cpp +++ b/src/mongo/db/repl/rollback_impl.cpp @@ -967,7 +967,7 @@ Status RollbackImpl::_processRollbackOp(OperationContext* opCtx, const OplogEntr _newCounts.erase(oplogEntry.getUuid().get()); } else if (oplogEntry.getCommandType() == OplogEntry::CommandType::kImportCollection) { auto importEntry = mongo::ImportCollectionOplogEntry::parse( - IDLParserErrorContext("importCollectionOplogEntry"), oplogEntry.getObject()); + IDLParserContext("importCollectionOplogEntry"), oplogEntry.getObject()); // Nothing to roll back if this is a dryRun. if (!importEntry.getDryRun()) { const auto& catalogEntry = importEntry.getCatalogEntry(); diff --git a/src/mongo/db/repl/session_update_tracker.cpp b/src/mongo/db/repl/session_update_tracker.cpp index 175c8ffc07e..d2068db886d 100644 --- a/src/mongo/db/repl/session_update_tracker.cpp +++ b/src/mongo/db/repl/session_update_tracker.cpp @@ -287,7 +287,7 @@ std::vector<OplogEntry> SessionUpdateTracker::flushAll() { std::vector<OplogEntry> SessionUpdateTracker::_flushForQueryPredicate( const BSONObj& queryPredicate) { auto idField = queryPredicate["_id"].Obj(); - auto lsid = LogicalSessionId::parse(IDLParserErrorContext("lsidInOplogQuery"), idField); + auto lsid = LogicalSessionId::parse(IDLParserContext("lsidInOplogQuery"), idField); auto iter = _sessionsToUpdate.find(lsid); if (iter == _sessionsToUpdate.end()) { diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 0fcd6083e77..384226d7675 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -121,7 +121,7 @@ StatusWith<int> StorageInterfaceImpl::getRollbackID(OperationContext* opCtx) { return rbidDoc.getStatus(); } - auto rbid = RollbackID::parse(IDLParserErrorContext("RollbackID"), rbidDoc.getValue()); + auto rbid = RollbackID::parse(IDLParserContext("RollbackID"), rbidDoc.getValue()); invariant(rbid.get_id() == kRollbackIdDocumentId); return rbid.getRollbackId(); } catch (const DBException&) { diff --git a/src/mongo/db/repl/storage_timestamp_test.cpp b/src/mongo/db/repl/storage_timestamp_test.cpp index 4f3f5bf0a18..359cb986fb9 100644 --- a/src/mongo/db/repl/storage_timestamp_test.cpp +++ b/src/mongo/db/repl/storage_timestamp_test.cpp @@ -504,7 +504,7 @@ public: OneOffRead oor(_opCtx, ts); auto doc = - repl::MinValidDocument::parse(IDLParserErrorContext("MinValidDocument"), findOne(coll)); + repl::MinValidDocument::parse(IDLParserContext("MinValidDocument"), findOne(coll)); ASSERT_EQ(expectedDoc.getMinValidTimestamp(), doc.getMinValidTimestamp()) << "minValid timestamps weren't equal at " << ts.toString() << ". Expected: " << expectedDoc.toBSON() << ". Found: " << doc.toBSON(); diff --git a/src/mongo/db/repl/tenant_database_cloner.cpp b/src/mongo/db/repl/tenant_database_cloner.cpp index 2df108b4da7..32f4c6efc53 100644 --- a/src/mongo/db/repl/tenant_database_cloner.cpp +++ b/src/mongo/db/repl/tenant_database_cloner.cpp @@ -138,7 +138,7 @@ BaseCloner::AfterStageBehavior TenantDatabaseCloner::listCollectionsStage() { ListCollectionResult result; try { result = ListCollectionResult::parse( - IDLParserErrorContext("TenantDatabaseCloner::listCollectionsStage"), info); + IDLParserContext("TenantDatabaseCloner::listCollectionsStage"), info); } catch (const DBException& e) { uasserted( ErrorCodes::FailedToParse, @@ -203,7 +203,7 @@ BaseCloner::AfterStageBehavior TenantDatabaseCloner::listExistingCollectionsStag ListCollectionResult result; try { result = ListCollectionResult::parse( - IDLParserErrorContext("TenantDatabaseCloner::listExistingCollectionsStage"), info); + IDLParserContext("TenantDatabaseCloner::listExistingCollectionsStage"), info); } catch (const DBException& e) { uasserted( ErrorCodes::FailedToParse, diff --git a/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp b/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp index 6689604b762..87c380f153f 100644 --- a/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp +++ b/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp @@ -127,7 +127,7 @@ boost::optional<std::string> parseTenantIdFromDB(StringData dbName) { TenantMigrationDonorDocument parseDonorStateDocument(const BSONObj& doc) { auto donorStateDoc = - TenantMigrationDonorDocument::parse(IDLParserErrorContext("donorStateDoc"), doc); + TenantMigrationDonorDocument::parse(IDLParserContext("donorStateDoc"), doc); if (donorStateDoc.getExpireAt()) { uassert(ErrorCodes::BadValue, diff --git a/src/mongo/db/repl/tenant_migration_recipient_entry_helpers.cpp b/src/mongo/db/repl/tenant_migration_recipient_entry_helpers.cpp index e62a6121b36..5b0c4172c17 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_entry_helpers.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_entry_helpers.cpp @@ -157,7 +157,7 @@ StatusWith<TenantMigrationRecipientDocument> getStateDoc(OperationContext* opCtx } try { - return TenantMigrationRecipientDocument::parse(IDLParserErrorContext("recipientStateDoc"), + return TenantMigrationRecipientDocument::parse(IDLParserContext("recipientStateDoc"), result); } catch (DBException& ex) { return ex.toStatus( diff --git a/src/mongo/db/repl/tenant_migration_recipient_op_observer.cpp b/src/mongo/db/repl/tenant_migration_recipient_op_observer.cpp index 468bf04d2b0..77b16a52436 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_op_observer.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_op_observer.cpp @@ -169,7 +169,7 @@ void TenantMigrationRecipientOpObserver::onUpdate(OperationContext* opCtx, if (args.nss == NamespaceString::kTenantMigrationRecipientsNamespace && !tenant_migration_access_blocker::inRecoveryMode(opCtx)) { auto recipientStateDoc = TenantMigrationRecipientDocument::parse( - IDLParserErrorContext("recipientStateDoc"), args.updateArgs->updatedDoc); + IDLParserContext("recipientStateDoc"), args.updateArgs->updatedDoc); opCtx->recoveryUnit()->onCommit([opCtx, recipientStateDoc](boost::optional<Timestamp>) { auto mtab = tenant_migration_access_blocker::getTenantMigrationRecipientAccessBlocker( opCtx->getServiceContext(), recipientStateDoc.getTenantId()); @@ -252,8 +252,8 @@ void TenantMigrationRecipientOpObserver::aboutToDelete(OperationContext* opCtx, BSONObj const& doc) { if (nss == NamespaceString::kTenantMigrationRecipientsNamespace && !tenant_migration_access_blocker::inRecoveryMode(opCtx)) { - auto recipientStateDoc = TenantMigrationRecipientDocument::parse( - IDLParserErrorContext("recipientStateDoc"), doc); + auto recipientStateDoc = + TenantMigrationRecipientDocument::parse(IDLParserContext("recipientStateDoc"), doc); uassert(ErrorCodes::IllegalOperation, str::stream() << "cannot delete a recipient's state document " << doc << " since it has not been marked as garbage collectable", diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp index f3d3e66804b..699428f1599 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp @@ -357,8 +357,8 @@ TenantMigrationRecipientService::Instance::Instance( : PrimaryOnlyService::TypedInstance<Instance>(), _serviceContext(serviceContext), _recipientService(recipientService), - _stateDoc(TenantMigrationRecipientDocument::parse(IDLParserErrorContext("recipientStateDoc"), - stateDoc)), + _stateDoc( + TenantMigrationRecipientDocument::parse(IDLParserContext("recipientStateDoc"), stateDoc)), _tenantId(_stateDoc.getTenantId().toString()), _protocol(_stateDoc.getProtocol().value_or(MigrationProtocolEnum::kMultitenantMigrations)), _migrationUuid(_stateDoc.getId()), @@ -460,8 +460,8 @@ boost::optional<BSONObj> TenantMigrationRecipientService::Instance::reportForCur void TenantMigrationRecipientService::Instance::checkIfOptionsConflict( const BSONObj& options) const { - auto stateDoc = TenantMigrationRecipientDocument::parse( - IDLParserErrorContext("recipientStateDoc"), options); + auto stateDoc = + TenantMigrationRecipientDocument::parse(IDLParserContext("recipientStateDoc"), options); invariant(stateDoc.getId() == _migrationUuid); @@ -1287,8 +1287,7 @@ TenantMigrationRecipientService::Instance::_makeCommittedTransactionsAggregation void TenantMigrationRecipientService::Instance::_processCommittedTransactionEntry( const BSONObj& entry) { - auto sessionTxnRecord = - SessionTxnRecord::parse(IDLParserErrorContext("SessionTxnRecord"), entry); + auto sessionTxnRecord = SessionTxnRecord::parse(IDLParserContext("SessionTxnRecord"), entry); auto sessionId = sessionTxnRecord.getSessionId(); auto txnNumber = sessionTxnRecord.getTxnNum(); auto optTxnRetryCounter = sessionTxnRecord.getTxnRetryCounter(); diff --git a/src/mongo/db/repl/tenant_migration_util.cpp b/src/mongo/db/repl/tenant_migration_util.cpp index 51d635d72d9..c89f933bb2c 100644 --- a/src/mongo/db/repl/tenant_migration_util.cpp +++ b/src/mongo/db/repl/tenant_migration_util.cpp @@ -69,7 +69,7 @@ MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationBeforeStoringExternalClusterTimeKeyD const Backoff kExponentialBackoff(Seconds(1), Milliseconds::max()); ExternalKeysCollectionDocument makeExternalClusterTimeKeyDoc(UUID migrationId, BSONObj keyDoc) { - auto originalKeyDoc = KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), keyDoc); + auto originalKeyDoc = KeysCollectionDocument::parse(IDLParserContext("keyDoc"), keyDoc); ExternalKeysCollectionDocument externalKeyDoc( OID::gen(), originalKeyDoc.getKeyId(), migrationId); diff --git a/src/mongo/db/repl/transaction_oplog_application.cpp b/src/mongo/db/repl/transaction_oplog_application.cpp index d55bcdbd710..7500dac2d55 100644 --- a/src/mongo/db/repl/transaction_oplog_application.cpp +++ b/src/mongo/db/repl/transaction_oplog_application.cpp @@ -184,7 +184,7 @@ repl::OplogEntry getPreviousOplogEntry(OperationContext* opCtx, const repl::Oplo Status applyCommitTransaction(OperationContext* opCtx, const OplogEntry& entry, repl::OplogApplication::Mode mode) { - IDLParserErrorContext ctx("commitTransaction"); + IDLParserContext ctx("commitTransaction"); auto commitOplogEntryOpTime = entry.getOpTime(); auto commitCommand = CommitTransactionOplogObject::parse(ctx, entry.getObject()); invariant(commitCommand.getCommitTimestamp()); @@ -595,7 +595,7 @@ void reconstructPreparedTransactions(OperationContext* opCtx, repl::OplogApplica while (cursor->more()) { const auto txnRecordObj = cursor->next(); const auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("recovering prepared transaction"), txnRecordObj); + IDLParserContext("recovering prepared transaction"), txnRecordObj); invariant(txnRecord.getState() == DurableTxnStateEnum::kPrepared); diff --git a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp index 208f96a13ef..aca57e115c9 100644 --- a/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp +++ b/src/mongo/db/s/balancer/balancer_chunk_selection_policy_impl.cpp @@ -152,7 +152,7 @@ getDataSizeInfoForCollections(OperationContext* opCtx, const ShardsvrGetStatsForBalancingReply reply = ShardsvrGetStatsForBalancingReply::parse( - IDLParserErrorContext("ShardsvrGetStatsForBalancingReply"), + IDLParserContext("ShardsvrGetStatsForBalancingReply"), std::move(responseValue.data)); const auto collStatsFromShard = reply.getStats(); diff --git a/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp b/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp index 7ebe9dac42c..3bc4f16bc89 100644 --- a/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp +++ b/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp @@ -328,7 +328,7 @@ SemiFuture<AutoSplitVectorResponse> BalancerCommandsSchedulerImpl::requestAutoSp if (!responseStatus.isOK()) { return responseStatus; } - return AutoSplitVectorResponse::parse(IDLParserErrorContext("AutoSplitVectorResponse"), + return AutoSplitVectorResponse::parse(IDLParserContext("AutoSplitVectorResponse"), std::move(remoteResponse.data)); }) .semi(); diff --git a/src/mongo/db/s/balancer/balancer_defragmentation_policy_test.cpp b/src/mongo/db/s/balancer/balancer_defragmentation_policy_test.cpp index a34c79ffc33..1512beb054c 100644 --- a/src/mongo/db/s/balancer/balancer_defragmentation_policy_test.cpp +++ b/src/mongo/db/s/balancer/balancer_defragmentation_policy_test.cpp @@ -170,7 +170,7 @@ protected: .getValue(); if (expectedPhase.has_value()) { auto storedDefragmentationPhase = DefragmentationPhase_parse( - IDLParserErrorContext("BalancerDefragmentationPolicyTest"), + IDLParserContext("BalancerDefragmentationPolicyTest"), configDoc.getStringField(CollectionType::kDefragmentationPhaseFieldName)); ASSERT_TRUE(storedDefragmentationPhase == *expectedPhase); } else { diff --git a/src/mongo/db/s/balancer/type_migration.cpp b/src/mongo/db/s/balancer/type_migration.cpp index cd50dce077d..4f1a4ac71b1 100644 --- a/src/mongo/db/s/balancer/type_migration.cpp +++ b/src/mongo/db/s/balancer/type_migration.cpp @@ -136,8 +136,8 @@ StatusWith<MigrationType> MigrationType::fromBSON(const BSONObj& source) { if (!status.isOK()) return status; - migrationType._forceJumbo = ForceJumbo_parse(IDLParserErrorContext("ForceJumbo"), - static_cast<int32_t>(forceJumboVal)); + migrationType._forceJumbo = + ForceJumbo_parse(IDLParserContext("ForceJumbo"), static_cast<int32_t>(forceJumboVal)); } { diff --git a/src/mongo/db/s/clone_catalog_data_command.cpp b/src/mongo/db/s/clone_catalog_data_command.cpp index 692bed243fd..b0df5c0cb98 100644 --- a/src/mongo/db/s/clone_catalog_data_command.cpp +++ b/src/mongo/db/s/clone_catalog_data_command.cpp @@ -100,7 +100,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(getName(), opCtx->getWriteConcern()); const auto cloneCatalogDataRequest = - CloneCatalogData::parse(IDLParserErrorContext("_shardsvrCloneCatalogData"), cmdObj); + CloneCatalogData::parse(IDLParserContext("_shardsvrCloneCatalogData"), cmdObj); const auto dbname = cloneCatalogDataRequest.getCommandParameter().toString(); uassert( diff --git a/src/mongo/db/s/collmod_coordinator.cpp b/src/mongo/db/s/collmod_coordinator.cpp index 06e8cd028dd..b7b0f160035 100644 --- a/src/mongo/db/s/collmod_coordinator.cpp +++ b/src/mongo/db/s/collmod_coordinator.cpp @@ -82,7 +82,7 @@ CollModCoordinator::CollModCoordinator(ShardingDDLCoordinatorService* service, void CollModCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { const auto otherDoc = - CollModCoordinatorDocument::parse(IDLParserErrorContext("CollModCoordinatorDocument"), doc); + CollModCoordinatorDocument::parse(IDLParserContext("CollModCoordinatorDocument"), doc); const auto& selfReq = _request.toBSON(); const auto& otherReq = otherDoc.getCollModRequest().toBSON(); diff --git a/src/mongo/db/s/config/config_server_test_fixture.cpp b/src/mongo/db/s/config/config_server_test_fixture.cpp index 15a25e430f8..2d845151764 100644 --- a/src/mongo/db/s/config/config_server_test_fixture.cpp +++ b/src/mongo/db/s/config/config_server_test_fixture.cpp @@ -445,7 +445,7 @@ std::vector<KeysCollectionDocument> ConfigServerTestFixture::getKeys(OperationCo std::vector<KeysCollectionDocument> keys; const auto& docs = findStatus.getValue().docs; for (const auto& doc : docs) { - auto key = KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), doc); + auto key = KeysCollectionDocument::parse(IDLParserContext("keyDoc"), doc); keys.push_back(std::move(key)); } diff --git a/src/mongo/db/s/config/configsvr_coordinator.cpp b/src/mongo/db/s/config/configsvr_coordinator.cpp index 8952273e8eb..0cbfecadac1 100644 --- a/src/mongo/db/s/config/configsvr_coordinator.cpp +++ b/src/mongo/db/s/config/configsvr_coordinator.cpp @@ -50,8 +50,8 @@ const Backoff kExponentialBackoff(Seconds(1), Milliseconds::max()); } // namespace ConfigsvrCoordinatorMetadata extractConfigsvrCoordinatorMetadata(const BSONObj& stateDoc) { - return ConfigsvrCoordinatorMetadata::parse( - IDLParserErrorContext("ConfigsvrCoordinatorMetadata"), stateDoc); + return ConfigsvrCoordinatorMetadata::parse(IDLParserContext("ConfigsvrCoordinatorMetadata"), + stateDoc); } ConfigsvrCoordinator::ConfigsvrCoordinator(const BSONObj& stateDoc) diff --git a/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp b/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp index 36543c7cbaa..2eeaacf5ea0 100644 --- a/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp +++ b/src/mongo/db/s/config/set_cluster_parameter_coordinator.cpp @@ -58,8 +58,8 @@ const WriteConcernOptions kMajorityWriteConcern{WriteConcernOptions::kMajority, } bool SetClusterParameterCoordinator::hasSameOptions(const BSONObj& otherDocBSON) const { - const auto otherDoc = StateDoc::parse( - IDLParserErrorContext("SetClusterParameterCoordinatorDocument"), otherDocBSON); + const auto otherDoc = + StateDoc::parse(IDLParserContext("SetClusterParameterCoordinatorDocument"), otherDocBSON); return SimpleBSONObjComparator::kInstance.evaluate(_doc.getParameter() == otherDoc.getParameter()); } diff --git a/src/mongo/db/s/config/set_cluster_parameter_coordinator.h b/src/mongo/db/s/config/set_cluster_parameter_coordinator.h index 2e172991a00..167898c2ecd 100644 --- a/src/mongo/db/s/config/set_cluster_parameter_coordinator.h +++ b/src/mongo/db/s/config/set_cluster_parameter_coordinator.h @@ -42,7 +42,7 @@ public: explicit SetClusterParameterCoordinator(const BSONObj& stateDoc) : ConfigsvrCoordinator(stateDoc), - _doc(StateDoc::parse(IDLParserErrorContext("SetClusterParameterCoordinatorDocument"), + _doc(StateDoc::parse(IDLParserContext("SetClusterParameterCoordinatorDocument"), stateDoc)) {} bool hasSameOptions(const BSONObj& participantDoc) const override; diff --git a/src/mongo/db/s/config/set_user_write_block_mode_coordinator.cpp b/src/mongo/db/s/config/set_user_write_block_mode_coordinator.cpp index 2c3139f0cff..ecd04057546 100644 --- a/src/mongo/db/s/config/set_user_write_block_mode_coordinator.cpp +++ b/src/mongo/db/s/config/set_user_write_block_mode_coordinator.cpp @@ -84,8 +84,8 @@ void sendSetUserWriteBlockModeCmdToAllShards(OperationContext* opCtx, } // namespace bool SetUserWriteBlockModeCoordinator::hasSameOptions(const BSONObj& otherDocBSON) const { - const auto otherDoc = StateDoc::parse( - IDLParserErrorContext("SetUserWriteBlockModeCoordinatorDocument"), otherDocBSON); + const auto otherDoc = + StateDoc::parse(IDLParserContext("SetUserWriteBlockModeCoordinatorDocument"), otherDocBSON); return _doc.getBlock() == otherDoc.getBlock(); } diff --git a/src/mongo/db/s/config/set_user_write_block_mode_coordinator.h b/src/mongo/db/s/config/set_user_write_block_mode_coordinator.h index be51f32f014..8ac13d5aca6 100644 --- a/src/mongo/db/s/config/set_user_write_block_mode_coordinator.h +++ b/src/mongo/db/s/config/set_user_write_block_mode_coordinator.h @@ -42,7 +42,7 @@ public: explicit SetUserWriteBlockModeCoordinator(const BSONObj& stateDoc) : ConfigsvrCoordinator(stateDoc), - _doc(StateDoc::parse(IDLParserErrorContext("SetUserWriteBlockModeCoordinatorDocument"), + _doc(StateDoc::parse(IDLParserContext("SetUserWriteBlockModeCoordinatorDocument"), stateDoc)) {} bool hasSameOptions(const BSONObj& participantDoc) const override; diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp index bfef69bcb9f..3ae9a91fce5 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp @@ -283,8 +283,8 @@ protected: const auto addShardOpMsgRequest = OpMsgRequest::fromDBAndBody(request.dbname, request.cmdObj); - auto addShardCmd = AddShard::parse(IDLParserErrorContext(AddShard::kCommandName), - addShardOpMsgRequest); + auto addShardCmd = + AddShard::parse(IDLParserContext(AddShard::kCommandName), addShardOpMsgRequest); const auto& updateOpField = add_shard_util::createShardIdentityUpsertForAddShard(addShardCmd); diff --git a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp index 2af9f43bc2d..f3f2a6fd4a6 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp @@ -134,7 +134,7 @@ DatabaseType ShardingCatalogManager::createDatabase( auto dbObj = client.findOne(NamespaceString::kConfigDatabasesNamespace, dbMatchFilter); if (!dbObj.isEmpty()) { replClient.setLastOpToSystemLastOpTime(opCtx); - return DatabaseType::parse(IDLParserErrorContext("DatabaseType"), std::move(dbObj)); + return DatabaseType::parse(IDLParserContext("DatabaseType"), std::move(dbObj)); } if (dbLock) { @@ -160,7 +160,7 @@ DatabaseType ShardingCatalogManager::createDatabase( auto dbDoc = client.findOne(NamespaceString::kConfigDatabasesNamespace, queryBuilder.obj()); auto const [primaryShardPtr, database] = [&] { if (!dbDoc.isEmpty()) { - auto actualDb = DatabaseType::parse(IDLParserErrorContext("DatabaseType"), dbDoc); + auto actualDb = DatabaseType::parse(IDLParserContext("DatabaseType"), dbDoc); uassert(ErrorCodes::DatabaseDifferCase, str::stream() << "can't have 2 databases that just differ on case " diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp index 23be2f5d94f..f023a4457df 100644 --- a/src/mongo/db/s/create_collection_coordinator.cpp +++ b/src/mongo/db/s/create_collection_coordinator.cpp @@ -323,7 +323,7 @@ const NamespaceString& CreateCollectionCoordinator::nss() const { void CreateCollectionCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { // If we have two shard collections on the same namespace, then the arguments must be the same. const auto otherDoc = CreateCollectionCoordinatorDocument::parse( - IDLParserErrorContext("CreateCollectionCoordinatorDocument"), doc); + IDLParserContext("CreateCollectionCoordinatorDocument"), doc); uassert(ErrorCodes::ConflictingOperationInProgress, "Another create collection with different arguments is already running for the same " @@ -601,7 +601,7 @@ void CreateCollectionCoordinator::_createCollectionAndIndexes(OperationContext* boost::optional<Collation> collation; if (!collationBSON.isEmpty()) { collation.emplace( - Collation::parse(IDLParserErrorContext("CreateCollectionCoordinator"), collationBSON)); + Collation::parse(IDLParserContext("CreateCollectionCoordinator"), collationBSON)); } // We need to implicitly create a timeseries view and underlying bucket collection. diff --git a/src/mongo/db/s/forwardable_operation_metadata.cpp b/src/mongo/db/s/forwardable_operation_metadata.cpp index 1a83a2eb1f1..51c06f80347 100644 --- a/src/mongo/db/s/forwardable_operation_metadata.cpp +++ b/src/mongo/db/s/forwardable_operation_metadata.cpp @@ -39,7 +39,7 @@ namespace mongo { ForwardableOperationMetadata::ForwardableOperationMetadata(const BSONObj& obj) { ForwardableOperationMetadataBase::parseProtected( - IDLParserErrorContext("ForwardableOperationMetadataBase"), obj); + IDLParserContext("ForwardableOperationMetadataBase"), obj); } ForwardableOperationMetadata::ForwardableOperationMetadata(OperationContext* opCtx) { diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp index f0d85e91d0a..52fc0fdaa7a 100644 --- a/src/mongo/db/s/migration_util.cpp +++ b/src/mongo/db/s/migration_util.cpp @@ -525,7 +525,7 @@ void resubmitRangeDeletionsOnStepUp(ServiceContext* serviceContext) { while (cursor->more()) { retFuture = migrationutil::submitRangeDeletionTask( opCtx.get(), - RangeDeletionTask::parse(IDLParserErrorContext("rangeDeletionRecovery"), + RangeDeletionTask::parse(IDLParserContext("rangeDeletionRecovery"), cursor->next())); rangeDeletionsMarkedAsProcessing++; } diff --git a/src/mongo/db/s/move_primary_coordinator.cpp b/src/mongo/db/s/move_primary_coordinator.cpp index 863a4c17b9d..95f4b851cc5 100644 --- a/src/mongo/db/s/move_primary_coordinator.cpp +++ b/src/mongo/db/s/move_primary_coordinator.cpp @@ -54,7 +54,7 @@ void MovePrimaryCoordinator::appendCommandInfo(BSONObjBuilder* cmdInfoBuilder) c void MovePrimaryCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { // If we have two shard collections on the same namespace, then the arguments must be the same. const auto otherDoc = MovePrimaryCoordinatorDocument::parse( - IDLParserErrorContext("MovePrimaryCoordinatorDocument"), doc); + IDLParserContext("MovePrimaryCoordinatorDocument"), doc); uassert( ErrorCodes::ConflictingOperationInProgress, diff --git a/src/mongo/db/s/move_primary_source_manager.cpp b/src/mongo/db/s/move_primary_source_manager.cpp index e016d060f09..5292e7ce66d 100644 --- a/src/mongo/db/s/move_primary_source_manager.cpp +++ b/src/mongo/db/s/move_primary_source_manager.cpp @@ -345,7 +345,7 @@ Status MovePrimarySourceManager::_commitOnConfig(OperationContext* opCtx) { !databasesVector.empty()); const auto dbType = - DatabaseType::parse(IDLParserErrorContext("DatabaseType"), databasesVector.front()); + DatabaseType::parse(IDLParserContext("DatabaseType"), databasesVector.front()); if (dbType.getPrimary() == _toShard) { return Status::OK(); diff --git a/src/mongo/db/s/persistent_task_queue.h b/src/mongo/db/s/persistent_task_queue.h index c1802278afe..32a1b4210fc 100644 --- a/src/mongo/db/s/persistent_task_queue.h +++ b/src/mongo/db/s/persistent_task_queue.h @@ -226,7 +226,7 @@ PersistentTaskQueue<T>::_loadNextRecord(DBDirectClient& client) { if (!bson.isEmpty()) { result = typename PersistentTaskQueue<T>::Record{ bson.getField("_id").Long(), - T::parse(IDLParserErrorContext("PersistentTaskQueue:" + _storageNss.toString()), + T::parse(IDLParserContext("PersistentTaskQueue:" + _storageNss.toString()), bson.getObjectField("task"))}; } diff --git a/src/mongo/db/s/persistent_task_queue_test.cpp b/src/mongo/db/s/persistent_task_queue_test.cpp index 55f490d9a7f..17b7a568613 100644 --- a/src/mongo/db/s/persistent_task_queue_test.cpp +++ b/src/mongo/db/s/persistent_task_queue_test.cpp @@ -49,7 +49,7 @@ struct TestTask { TestTask(BSONObj bson) : key(bson.getField("key").String()), val(bson.getField("value").Int()) {} - static TestTask parse(IDLParserErrorContext, BSONObj bson) { + static TestTask parse(IDLParserContext, BSONObj bson) { return TestTask{bson}; } diff --git a/src/mongo/db/s/recoverable_critical_section_service.cpp b/src/mongo/db/s/recoverable_critical_section_service.cpp index dbf5b492f71..57bf7501caa 100644 --- a/src/mongo/db/s/recoverable_critical_section_service.cpp +++ b/src/mongo/db/s/recoverable_critical_section_service.cpp @@ -112,7 +112,7 @@ void RecoverableCriticalSectionService::acquireRecoverableCriticalSectionBlockWr if (cursor->more()) { const auto bsonObj = cursor->next(); const auto collCSDoc = CollectionCriticalSectionDocument::parse( - IDLParserErrorContext("AcquireRecoverableCSBW"), bsonObj); + IDLParserContext("AcquireRecoverableCSBW"), bsonObj); invariant(collCSDoc.getReason().woCompare(reason) == 0, str::stream() @@ -203,7 +203,7 @@ void RecoverableCriticalSectionService::promoteRecoverableCriticalSectionToBlock << " but the critical section wasn't acquired first blocking writers."); BSONObj bsonObj = cursor->next(); const auto collCSDoc = CollectionCriticalSectionDocument::parse( - IDLParserErrorContext("AcquireRecoverableCSBR"), bsonObj); + IDLParserContext("AcquireRecoverableCSBR"), bsonObj); invariant( collCSDoc.getReason().woCompare(reason) == 0, @@ -313,7 +313,7 @@ void RecoverableCriticalSectionService::releaseRecoverableCriticalSection( BSONObj bsonObj = cursor->next(); const auto collCSDoc = CollectionCriticalSectionDocument::parse( - IDLParserErrorContext("ReleaseRecoverableCS"), bsonObj); + IDLParserContext("ReleaseRecoverableCS"), bsonObj); invariant( collCSDoc.getReason().woCompare(reason) == 0, diff --git a/src/mongo/db/s/refine_collection_shard_key_coordinator.cpp b/src/mongo/db/s/refine_collection_shard_key_coordinator.cpp index bfeec770791..ae507094e83 100644 --- a/src/mongo/db/s/refine_collection_shard_key_coordinator.cpp +++ b/src/mongo/db/s/refine_collection_shard_key_coordinator.cpp @@ -94,7 +94,7 @@ RefineCollectionShardKeyCoordinator::RefineCollectionShardKeyCoordinator( void RefineCollectionShardKeyCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { // If we have two refine collections on the same namespace, then the arguments must be the same. const auto otherDoc = RefineCollectionShardKeyCoordinatorDocument::parse( - IDLParserErrorContext("RefineCollectionShardKeyCoordinatorDocument"), doc); + IDLParserContext("RefineCollectionShardKeyCoordinatorDocument"), doc); uassert(ErrorCodes::ConflictingOperationInProgress, "Another refine collection with different arguments is already running for the same " diff --git a/src/mongo/db/s/rename_collection_coordinator.cpp b/src/mongo/db/s/rename_collection_coordinator.cpp index bec561b6a2b..11a00d34f04 100644 --- a/src/mongo/db/s/rename_collection_coordinator.cpp +++ b/src/mongo/db/s/rename_collection_coordinator.cpp @@ -97,7 +97,7 @@ RenameCollectionCoordinator::RenameCollectionCoordinator(ShardingDDLCoordinatorS void RenameCollectionCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { const auto otherDoc = RenameCollectionCoordinatorDocument::parse( - IDLParserErrorContext("RenameCollectionCoordinatorDocument"), doc); + IDLParserContext("RenameCollectionCoordinatorDocument"), doc); const auto& selfReq = _request.toBSON(); const auto& otherReq = otherDoc.getRenameCollectionRequest().toBSON(); diff --git a/src/mongo/db/s/rename_collection_participant_service.cpp b/src/mongo/db/s/rename_collection_participant_service.cpp index 58ced2cc9ac..6fc4a2bed2f 100644 --- a/src/mongo/db/s/rename_collection_participant_service.cpp +++ b/src/mongo/db/s/rename_collection_participant_service.cpp @@ -155,7 +155,7 @@ RenameParticipantInstance::~RenameParticipantInstance() { bool RenameParticipantInstance::hasSameOptions(const BSONObj& participantDoc) { const auto otherDoc = RenameCollectionParticipantDocument::parse( - IDLParserErrorContext("RenameCollectionParticipantDocument"), participantDoc); + IDLParserContext("RenameCollectionParticipantDocument"), participantDoc); const auto& selfReq = _doc.getRenameCollectionRequest().toBSON(); const auto& otherReq = otherDoc.getRenameCollectionRequest().toBSON(); diff --git a/src/mongo/db/s/rename_collection_participant_service.h b/src/mongo/db/s/rename_collection_participant_service.h index 73da51667ec..0f683458122 100644 --- a/src/mongo/db/s/rename_collection_participant_service.h +++ b/src/mongo/db/s/rename_collection_participant_service.h @@ -86,7 +86,7 @@ public: explicit RenameParticipantInstance(const BSONObj& participantDoc) : _doc(RenameCollectionParticipantDocument::parse( - IDLParserErrorContext("RenameCollectionParticipantDocument"), participantDoc)) {} + IDLParserContext("RenameCollectionParticipantDocument"), participantDoc)) {} ~RenameParticipantInstance(); diff --git a/src/mongo/db/s/reshard_collection_coordinator.cpp b/src/mongo/db/s/reshard_collection_coordinator.cpp index da1c65e01d3..afb1a0f7ab4 100644 --- a/src/mongo/db/s/reshard_collection_coordinator.cpp +++ b/src/mongo/db/s/reshard_collection_coordinator.cpp @@ -112,7 +112,7 @@ ReshardCollectionCoordinator::ReshardCollectionCoordinator(ShardingDDLCoordinato void ReshardCollectionCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { const auto otherDoc = ReshardCollectionCoordinatorDocument::parse( - IDLParserErrorContext("ReshardCollectionCoordinatorDocument"), doc); + IDLParserContext("ReshardCollectionCoordinatorDocument"), doc); uassert(ErrorCodes::ConflictingOperationInProgress, "Another reshard collection with different arguments is already running for the same " diff --git a/src/mongo/db/s/resharding/document_source_resharding_iterate_transaction.cpp b/src/mongo/db/s/resharding/document_source_resharding_iterate_transaction.cpp index 60f034dcfea..c37eb05fc80 100644 --- a/src/mongo/db/s/resharding/document_source_resharding_iterate_transaction.cpp +++ b/src/mongo/db/s/resharding/document_source_resharding_iterate_transaction.cpp @@ -192,8 +192,7 @@ DocumentSource::GetNextResult DocumentSourceReshardingIterateTransaction::doGetN bool DocumentSourceReshardingIterateTransaction::_isTransactionOplogEntry(const Document& doc) { auto op = doc[repl::OplogEntry::kOpTypeFieldName]; - auto opType = - repl::OpType_parse(IDLParserErrorContext("ReshardingEntry.op"), op.getStringData()); + auto opType = repl::OpType_parse(IDLParserContext("ReshardingEntry.op"), op.getStringData()); auto commandVal = doc["o"]; if (opType != repl::OpTypeEnum::kCommand || doc["txnNumber"].missing() || diff --git a/src/mongo/db/s/resharding/resharding_agg_test.cpp b/src/mongo/db/s/resharding/resharding_agg_test.cpp index c49467f79f9..9c2f9fcba23 100644 --- a/src/mongo/db/s/resharding/resharding_agg_test.cpp +++ b/src/mongo/db/s/resharding/resharding_agg_test.cpp @@ -257,7 +257,7 @@ bool validateOplogId(const Timestamp& clusterTime, const mongo::Document& sourceDoc, const repl::OplogEntry& oplogEntry) { auto oplogIdExpected = ReshardingDonorOplogId{clusterTime, sourceDoc["ts"].getTimestamp()}; - auto oplogId = ReshardingDonorOplogId::parse(IDLParserErrorContext("ReshardingAggTest"), + auto oplogId = ReshardingDonorOplogId::parse(IDLParserContext("ReshardingAggTest"), oplogEntry.get_id()->getDocument().toBson()); return oplogIdExpected == oplogId; } @@ -351,7 +351,7 @@ protected: ReshardingDonorOplogId getOplogId(const repl::MutableOplogEntry& oplog) { - return ReshardingDonorOplogId::parse(IDLParserErrorContext("ReshardingAggTest::getOplogId"), + return ReshardingDonorOplogId::parse(IDLParserContext("ReshardingAggTest::getOplogId"), oplog.get_id()->getDocument().toBson()); } diff --git a/src/mongo/db/s/resharding/resharding_coordinator_service.cpp b/src/mongo/db/s/resharding/resharding_coordinator_service.cpp index 00a5310b176..181024995d2 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_service.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_service.cpp @@ -980,7 +980,7 @@ std::shared_ptr<repl::PrimaryOnlyService::Instance> ReshardingCoordinatorService BSONObj initialState) { return std::make_shared<ReshardingCoordinator>( this, - ReshardingCoordinatorDocument::parse(IDLParserErrorContext("ReshardingCoordinatorStateDoc"), + ReshardingCoordinatorDocument::parse(IDLParserContext("ReshardingCoordinatorStateDoc"), std::move(initialState)), std::make_shared<ReshardingCoordinatorExternalStateImpl>(), _serviceContext); diff --git a/src/mongo/db/s/resharding/resharding_coordinator_service_test.cpp b/src/mongo/db/s/resharding/resharding_coordinator_service_test.cpp index fc4c6b722d9..a849cc5ca87 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_service_test.cpp @@ -116,8 +116,8 @@ public: std::shared_ptr<PrimaryOnlyService::Instance> constructInstance(BSONObj initialState) override { return std::make_shared<ReshardingCoordinator>( this, - ReshardingCoordinatorDocument::parse( - IDLParserErrorContext("ReshardingCoordinatorStateDoc"), std::move(initialState)), + ReshardingCoordinatorDocument::parse(IDLParserContext("ReshardingCoordinatorStateDoc"), + std::move(initialState)), std::make_shared<ExternalStateForTest>(), _serviceContext); } @@ -231,7 +231,7 @@ public: DBDirectClient client(opCtx); auto doc = client.findOne(NamespaceString::kConfigReshardingOperationsNamespace, BSONObj{}); - IDLParserErrorContext errCtx("reshardingCoordFromTest"); + IDLParserContext errCtx("reshardingCoordFromTest"); return ReshardingCoordinatorDocument::parse(errCtx, doc); } diff --git a/src/mongo/db/s/resharding/resharding_coordinator_test.cpp b/src/mongo/db/s/resharding/resharding_coordinator_test.cpp index 35ffa75b31a..a5236d91c5b 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_test.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_test.cpp @@ -248,7 +248,7 @@ protected: BSON("ns" << expectedCoordinatorDoc.getSourceNss().ns())); auto coordinatorDoc = ReshardingCoordinatorDocument::parse( - IDLParserErrorContext("ReshardingCoordinatorTest"), doc); + IDLParserContext("ReshardingCoordinatorTest"), doc); ASSERT_EQUALS(coordinatorDoc.getReshardingUUID(), expectedCoordinatorDoc.getReshardingUUID()); diff --git a/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp b/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp index 859450a3b6d..d81662f968c 100644 --- a/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp +++ b/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp @@ -355,7 +355,7 @@ TEST_F(DestinedRecipientTest, TestOpObserverSetsDestinedRecipientOnInsertsInTran auto info = repl::ApplyOpsCommandInfo::parse(entry.getOperationToApply()); auto ops = info.getOperations(); - auto replOp = repl::ReplOperation::parse(IDLParserErrorContext("insertOp"), ops[0]); + auto replOp = repl::ReplOperation::parse(IDLParserContext("insertOp"), ops[0]); ASSERT_EQ(replOp.getNss(), kNss); auto recipShard = replOp.getDestinedRecipient(); @@ -442,7 +442,7 @@ TEST_F(DestinedRecipientTest, TestOpObserverSetsDestinedRecipientOnUpdatesInTran auto info = repl::ApplyOpsCommandInfo::parse(entry.getOperationToApply()); auto ops = info.getOperations(); - auto replOp = repl::ReplOperation::parse(IDLParserErrorContext("insertOp"), ops[0]); + auto replOp = repl::ReplOperation::parse(IDLParserContext("insertOp"), ops[0]); ASSERT_EQ(replOp.getNss(), kNss); auto recipShard = replOp.getDestinedRecipient(); @@ -487,7 +487,7 @@ TEST_F(DestinedRecipientTest, TestOpObserverSetsDestinedRecipientOnDeletesInTran auto info = repl::ApplyOpsCommandInfo::parse(entry.getOperationToApply()); auto ops = info.getOperations(); - auto replOp = repl::ReplOperation::parse(IDLParserErrorContext("deleteOp"), ops[0]); + auto replOp = repl::ReplOperation::parse(IDLParserContext("deleteOp"), ops[0]); ASSERT_EQ(replOp.getNss(), kNss); auto recipShard = replOp.getDestinedRecipient(); diff --git a/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp b/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp index 0a9027deea2..5a9c8343fa2 100644 --- a/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp +++ b/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp @@ -66,7 +66,7 @@ namespace { */ ReshardingDonorOplogId getId(const repl::OplogEntry& oplog) { return ReshardingDonorOplogId::parse( - IDLParserErrorContext("ReshardingDonorOplogIterator::getOplogId"), + IDLParserContext("ReshardingDonorOplogIterator::getOplogId"), oplog.get_id()->getDocument().toBson()); } diff --git a/src/mongo/db/s/resharding/resharding_donor_service_test.cpp b/src/mongo/db/s/resharding/resharding_donor_service_test.cpp index 92f848d2d17..d4f5046e340 100644 --- a/src/mongo/db/s/resharding/resharding_donor_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_donor_service_test.cpp @@ -289,7 +289,7 @@ TEST_F(ReshardingDonorServiceTest, WritesNoOpOplogEntryOnReshardingBegin) { ReshardBeginChangeEventO2Field expectedChangeEvent{sourceNss, doc.getReshardingUUID()}; auto receivedChangeEvent = ReshardBeginChangeEventO2Field::parse( - IDLParserErrorContext("ReshardBeginChangeEventO2Field"), *op.getObject2()); + IDLParserContext("ReshardBeginChangeEventO2Field"), *op.getObject2()); ASSERT_EQ(OpType_serializer(op.getOpType()), OpType_serializer(repl::OpTypeEnum::kNoop)) << op.getEntry(); diff --git a/src/mongo/db/s/resharding/resharding_op_observer.cpp b/src/mongo/db/s/resharding/resharding_op_observer.cpp index 9fbfa40bf55..3441f7c1eea 100644 --- a/src/mongo/db/s/resharding/resharding_op_observer.cpp +++ b/src/mongo/db/s/resharding/resharding_op_observer.cpp @@ -60,7 +60,7 @@ std::shared_ptr<ReshardingCoordinatorObserver> getReshardingCoordinatorObserver( } boost::optional<Timestamp> parseNewMinFetchTimestampValue(const BSONObj& obj) { - auto doc = ReshardingDonorDocument::parse(IDLParserErrorContext("Resharding"), obj); + auto doc = ReshardingDonorDocument::parse(IDLParserContext("Resharding"), obj); if (doc.getMutableState().getState() == DonorStateEnum::kDonatingInitialData) { return doc.getMutableState().getMinFetchTimestamp().get(); } else { @@ -218,7 +218,7 @@ void ReshardingOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateEn if (args.nss == NamespaceString::kConfigReshardingOperationsNamespace) { auto newCoordinatorDoc = ReshardingCoordinatorDocument::parse( - IDLParserErrorContext("reshardingCoordinatorDoc"), args.updateArgs->updatedDoc); + IDLParserContext("reshardingCoordinatorDoc"), args.updateArgs->updatedDoc); opCtx->recoveryUnit()->onCommit([opCtx, newCoordinatorDoc = std::move(newCoordinatorDoc)]( boost::optional<Timestamp> unusedCommitTime) mutable { try { diff --git a/src/mongo/db/s/resharding/resharding_oplog_applier.cpp b/src/mongo/db/s/resharding/resharding_oplog_applier.cpp index d9edf786371..470b5b382d2 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_applier.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_applier.cpp @@ -220,7 +220,7 @@ boost::optional<ReshardingOplogApplierProgress> ReshardingOplogApplier::checkSto return boost::none; } - IDLParserErrorContext ctx("ReshardingOplogApplierProgress"); + IDLParserContext ctx("ReshardingOplogApplierProgress"); return ReshardingOplogApplierProgress::parse(ctx, doc); } diff --git a/src/mongo/db/s/resharding/resharding_recipient_service.cpp b/src/mongo/db/s/resharding/resharding_recipient_service.cpp index 21b3042fef6..9a63fe0daea 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service.cpp @@ -1200,7 +1200,7 @@ void ReshardingRecipientService::RecipientStateMachine::_restoreMetrics( if (!result.isEmpty()) { progressDoc = ReshardingOplogApplierProgress::parse( - IDLParserErrorContext("resharding-recipient-service-progress-doc"), result); + IDLParserContext("resharding-recipient-service-progress-doc"), result); oplogEntriesApplied += progressDoc->getNumEntriesApplied(); } } diff --git a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp index 26217cee42f..d054ae355ab 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp @@ -647,7 +647,7 @@ TEST_F(ReshardingRecipientServiceTest, WritesNoopOplogEntryOnReshardDoneCatchUp) ReshardDoneCatchUpChangeEventO2Field expectedChangeEvent{sourceNss, doc.getReshardingUUID()}; auto receivedChangeEvent = ReshardDoneCatchUpChangeEventO2Field::parse( - IDLParserErrorContext("ReshardDoneCatchUpChangeEventO2Field"), *op.getObject2()); + IDLParserContext("ReshardDoneCatchUpChangeEventO2Field"), *op.getObject2()); ASSERT_EQ(OpType_serializer(op.getOpType()), OpType_serializer(repl::OpTypeEnum::kNoop)) << op.getEntry(); diff --git a/src/mongo/db/s/resharding/resharding_txn_cloner_test.cpp b/src/mongo/db/s/resharding/resharding_txn_cloner_test.cpp index 24045678550..223da448f54 100644 --- a/src/mongo/db/s/resharding/resharding_txn_cloner_test.cpp +++ b/src/mongo/db/s/resharding/resharding_txn_cloner_test.cpp @@ -179,7 +179,7 @@ protected: } LogicalSessionId getTxnRecordLsid(BSONObj txnRecord) { - return SessionTxnRecord::parse(IDLParserErrorContext("ReshardingTxnClonerTest"), txnRecord) + return SessionTxnRecord::parse(IDLParserContext("ReshardingTxnClonerTest"), txnRecord) .getSessionId(); } @@ -272,7 +272,7 @@ protected: BSON(SessionTxnRecord::kSessionIdFieldName << sessionId.toBSON())); ASSERT(!bsonTxn.isEmpty()); auto txn = SessionTxnRecord::parse( - IDLParserErrorContext("resharding config transactions cloning test"), bsonTxn); + IDLParserContext("resharding config transactions cloning test"), bsonTxn); ASSERT_EQ(txn.getTxnNum(), txnNum); ASSERT_EQ(txn.getLastWriteOpTime(), oplogEntry.getOpTime()); } @@ -303,8 +303,8 @@ protected: return boost::none; } - return ReshardingTxnClonerProgress::parse( - IDLParserErrorContext("ReshardingTxnClonerProgress"), progressDoc); + return ReshardingTxnClonerProgress::parse(IDLParserContext("ReshardingTxnClonerProgress"), + progressDoc); } boost::optional<LogicalSessionId> getProgressLsid(const ReshardingSourceId& sourceId) { diff --git a/src/mongo/db/s/session_catalog_migration_source.cpp b/src/mongo/db/s/session_catalog_migration_source.cpp index e97005571ef..afa613481c6 100644 --- a/src/mongo/db/s/session_catalog_migration_source.cpp +++ b/src/mongo/db/s/session_catalog_migration_source.cpp @@ -78,7 +78,7 @@ boost::optional<repl::OplogEntry> forgeNoopEntryFromImageCollection( return boost::none; } - auto image = repl::ImageEntry::parse(IDLParserErrorContext("image entry"), imageObj); + auto image = repl::ImageEntry::parse(IDLParserContext("image entry"), imageObj); if (image.getTxnNumber() != retryableFindAndModifyOplogEntry.getTxnNumber()) { // In our snapshot, fetch the current transaction number for a session. If that transaction // number doesn't match what's found on the image lookup, it implies that the image is not @@ -243,8 +243,8 @@ SessionCatalogMigrationSource::SessionCatalogMigrationSource(OperationContext* o boost::optional<LastTxnSession> lastTxnSession; while (cursor->more()) { - const auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("Session migration cloning"), cursor->next()); + const auto txnRecord = + SessionTxnRecord::parse(IDLParserContext("Session migration cloning"), cursor->next()); const auto sessionId = txnRecord.getSessionId(); const auto parentSessionId = castToParentSessionId(sessionId); diff --git a/src/mongo/db/s/set_allow_migrations_coordinator.cpp b/src/mongo/db/s/set_allow_migrations_coordinator.cpp index d8cb15afb2e..ed1e55da18f 100644 --- a/src/mongo/db/s/set_allow_migrations_coordinator.cpp +++ b/src/mongo/db/s/set_allow_migrations_coordinator.cpp @@ -54,7 +54,7 @@ void SetAllowMigrationsCoordinator::checkIfOptionsConflict(const BSONObj& doc) c // If we have two set allow migrations on the same namespace, then the arguments must be the // same. const auto otherDoc = SetAllowMigrationsCoordinatorDocument::parse( - IDLParserErrorContext("SetAllowMigrationsCoordinatorDocument"), doc); + IDLParserContext("SetAllowMigrationsCoordinatorDocument"), doc); uassert(ErrorCodes::ConflictingOperationInProgress, "Another set allow migrations with different arguments is already running for the same " diff --git a/src/mongo/db/s/shard_metadata_util.cpp b/src/mongo/db/s/shard_metadata_util.cpp index e52a5e28d1a..ae0dedc5cfe 100644 --- a/src/mongo/db/s/shard_metadata_util.cpp +++ b/src/mongo/db/s/shard_metadata_util.cpp @@ -189,7 +189,7 @@ StatusWith<ShardDatabaseType> readShardDatabasesEntry(OperationContext* opCtx, S } BSONObj document = cursor->nextSafe(); - return ShardDatabaseType::parse(IDLParserErrorContext("ShardDatabaseType"), document); + return ShardDatabaseType::parse(IDLParserContext("ShardDatabaseType"), document); } catch (const DBException& ex) { return ex.toStatus(str::stream() << "Failed to read the '" << dbName.toString() << "' entry locally from " diff --git a/src/mongo/db/s/shard_server_op_observer.cpp b/src/mongo/db/s/shard_server_op_observer.cpp index 9179504e4f2..5069ac4613c 100644 --- a/src/mongo/db/s/shard_server_op_observer.cpp +++ b/src/mongo/db/s/shard_server_op_observer.cpp @@ -268,8 +268,8 @@ void ShardServerOpObserver::onInserts(OperationContext* opCtx, return; } - auto deletionTask = RangeDeletionTask::parse( - IDLParserErrorContext("ShardServerOpObserver"), insertedDoc); + auto deletionTask = + RangeDeletionTask::parse(IDLParserContext("ShardServerOpObserver"), insertedDoc); if (!deletionTask.getPending()) { opCtx->recoveryUnit()->registerChange( @@ -284,7 +284,7 @@ void ShardServerOpObserver::onInserts(OperationContext* opCtx, if (nss == NamespaceString::kCollectionCriticalSectionsNamespace && !recoverable_critical_section_util::inRecoveryMode(opCtx)) { const auto collCSDoc = CollectionCriticalSectionDocument::parse( - IDLParserErrorContext("ShardServerOpObserver"), insertedDoc); + IDLParserContext("ShardServerOpObserver"), insertedDoc); opCtx->recoveryUnit()->onCommit([opCtx, insertedNss = collCSDoc.getNss(), reason = collCSDoc.getReason().getOwned()]( @@ -411,8 +411,8 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE update_oplog_entry::isFieldRemovedByUpdate(args.updateArgs->update, "pending"); if (pendingFieldRemovedStatus == update_oplog_entry::FieldRemovedStatus::kFieldRemoved) { - auto deletionTask = RangeDeletionTask::parse( - IDLParserErrorContext("ShardServerOpObserver"), args.updateArgs->updatedDoc); + auto deletionTask = RangeDeletionTask::parse(IDLParserContext("ShardServerOpObserver"), + args.updateArgs->updatedDoc); if (deletionTask.getDonorShardId() != ShardingState::get(opCtx)->shardId()) { // Range deletion tasks for moved away chunks are scheduled through the @@ -426,7 +426,7 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE if (args.nss == NamespaceString::kCollectionCriticalSectionsNamespace && !recoverable_critical_section_util::inRecoveryMode(opCtx)) { const auto collCSDoc = CollectionCriticalSectionDocument::parse( - IDLParserErrorContext("ShardServerOpObserver"), args.updateArgs->updatedDoc); + IDLParserContext("ShardServerOpObserver"), args.updateArgs->updatedDoc); opCtx->recoveryUnit()->onCommit( [opCtx, updatedNss = collCSDoc.getNss(), reason = collCSDoc.getReason().getOwned()]( @@ -522,7 +522,7 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx, !recoverable_critical_section_util::inRecoveryMode(opCtx)) { const auto& deletedDoc = documentId; const auto collCSDoc = CollectionCriticalSectionDocument::parse( - IDLParserErrorContext("ShardServerOpObserver"), deletedDoc); + IDLParserContext("ShardServerOpObserver"), deletedDoc); opCtx->recoveryUnit()->onCommit( [opCtx, deletedNss = collCSDoc.getNss(), reason = collCSDoc.getReason().getOwned()]( diff --git a/src/mongo/db/s/sharding_ddl_coordinator.cpp b/src/mongo/db/s/sharding_ddl_coordinator.cpp index 4795370b17c..7d880424df3 100644 --- a/src/mongo/db/s/sharding_ddl_coordinator.cpp +++ b/src/mongo/db/s/sharding_ddl_coordinator.cpp @@ -74,8 +74,8 @@ bool isRetriableErrorForDDLCoordinator(const Status& status) { } // namespace ShardingDDLCoordinatorMetadata extractShardingDDLCoordinatorMetadata(const BSONObj& coorDoc) { - return ShardingDDLCoordinatorMetadata::parse( - IDLParserErrorContext("ShardingDDLCoordinatorMetadata"), coorDoc); + return ShardingDDLCoordinatorMetadata::parse(IDLParserContext("ShardingDDLCoordinatorMetadata"), + coorDoc); } ShardingDDLCoordinator::ShardingDDLCoordinator(ShardingDDLCoordinatorService* service, diff --git a/src/mongo/db/s/sharding_ddl_coordinator.h b/src/mongo/db/s/sharding_ddl_coordinator.h index 9119d44583d..66ec5706030 100644 --- a/src/mongo/db/s/sharding_ddl_coordinator.h +++ b/src/mongo/db/s/sharding_ddl_coordinator.h @@ -189,7 +189,7 @@ protected: : ShardingDDLCoordinator(service, initialStateDoc), _coordinatorName(name), _initialState(initialStateDoc.getOwned()), - _doc(StateDoc::parse(IDLParserErrorContext("CoordinatorDocument"), _initialState)) {} + _doc(StateDoc::parse(IDLParserContext("CoordinatorDocument"), _initialState)) {} ShardingDDLCoordinatorMetadata const& metadata() const override { return _doc.getShardingDDLCoordinatorMetadata(); diff --git a/src/mongo/db/s/shardsvr_collmod_command.cpp b/src/mongo/db/s/shardsvr_collmod_command.cpp index 96400a31776..b1bef41021e 100644 --- a/src/mongo/db/s/shardsvr_collmod_command.cpp +++ b/src/mongo/db/s/shardsvr_collmod_command.cpp @@ -127,7 +127,7 @@ public: void validateResult(const BSONObj& resultObj) final { StringDataSet ignorableFields({"raw", "ok", "errmsg"}); - auto reply = Response::parse(IDLParserErrorContext("CollModReply"), + auto reply = Response::parse(IDLParserContext("CollModReply"), resultObj.removeFields(ignorableFields)); coll_mod_reply_validation::validateReply(reply); } diff --git a/src/mongo/db/s/shardsvr_collmod_participant_command.cpp b/src/mongo/db/s/shardsvr_collmod_participant_command.cpp index 2a7e78886b2..64d7c97b798 100644 --- a/src/mongo/db/s/shardsvr_collmod_participant_command.cpp +++ b/src/mongo/db/s/shardsvr_collmod_participant_command.cpp @@ -122,7 +122,7 @@ public: auto performViewChange = request().getPerformViewChange(); uassertStatusOK(timeseries::processCollModCommandWithTimeSeriesTranslation( opCtx, ns(), cmd, performViewChange, &builder)); - return CollModReply::parse(IDLParserErrorContext("CollModReply"), builder.obj()); + return CollModReply::parse(IDLParserContext("CollModReply"), builder.obj()); } private: diff --git a/src/mongo/db/s/shardsvr_move_primary_command.cpp b/src/mongo/db/s/shardsvr_move_primary_command.cpp index 2fbb2f9362b..9cde19c4ee4 100644 --- a/src/mongo/db/s/shardsvr_move_primary_command.cpp +++ b/src/mongo/db/s/shardsvr_move_primary_command.cpp @@ -93,7 +93,7 @@ public: uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); const auto movePrimaryRequest = - ShardMovePrimary::parse(IDLParserErrorContext("_shardsvrMovePrimary"), cmdObj); + ShardMovePrimary::parse(IDLParserContext("_shardsvrMovePrimary"), cmdObj); const auto dbname = parseNs("", cmdObj); const NamespaceString dbNss(dbname); diff --git a/src/mongo/db/s/start_chunk_clone_request.cpp b/src/mongo/db/s/start_chunk_clone_request.cpp index 86567dce161..96854b8dd8a 100644 --- a/src/mongo/db/s/start_chunk_clone_request.cpp +++ b/src/mongo/db/s/start_chunk_clone_request.cpp @@ -154,7 +154,7 @@ StatusWith<StartChunkCloneRequest> StartChunkCloneRequest::createFromCommand(Nam request._migrationId = UUID::parse(obj); request._lsid = - LogicalSessionId::parse(IDLParserErrorContext("StartChunkCloneRequest"), obj[kLsid].Obj()); + LogicalSessionId::parse(IDLParserContext("StartChunkCloneRequest"), obj[kLsid].Obj()); request._txnNumber = obj.getField(kTxnNumber).Long(); return request; diff --git a/src/mongo/db/s/transaction_coordinator_structures_test.cpp b/src/mongo/db/s/transaction_coordinator_structures_test.cpp index df1d3cc2ade..587c8d16ae0 100644 --- a/src/mongo/db/s/transaction_coordinator_structures_test.cpp +++ b/src/mongo/db/s/transaction_coordinator_structures_test.cpp @@ -64,7 +64,7 @@ TEST(CoordinatorCommitDecisionTest, SerializeAbortHasNoTimestampAndAbortStatus) ASSERT_BSONOBJ_EQ(expectedObj, obj); auto deserializedDecision = - CoordinatorCommitDecision::parse(IDLParserErrorContext("AbortTest"), expectedObj); + CoordinatorCommitDecision::parse(IDLParserContext("AbortTest"), expectedObj); ASSERT_BSONOBJ_EQ(obj, deserializedDecision.toBSON()); } diff --git a/src/mongo/db/s/transaction_coordinator_test.cpp b/src/mongo/db/s/transaction_coordinator_test.cpp index b4a643339e6..9c02733fdb0 100644 --- a/src/mongo/db/s/transaction_coordinator_test.cpp +++ b/src/mongo/db/s/transaction_coordinator_test.cpp @@ -160,7 +160,7 @@ protected: TransactionCoordinatorDocument doc; do { doc = TransactionCoordinatorDocument::parse( - IDLParserErrorContext("dummy"), + IDLParserContext("dummy"), dbClient.findOne(NamespaceString::kTransactionCoordinatorsNamespace, BSONObj{})); } while (!doc.getDecision()); } diff --git a/src/mongo/db/s/transaction_coordinator_util.cpp b/src/mongo/db/s/transaction_coordinator_util.cpp index 252ec91dd15..c591bf839da 100644 --- a/src/mongo/db/s/transaction_coordinator_util.cpp +++ b/src/mongo/db/s/transaction_coordinator_util.cpp @@ -664,7 +664,7 @@ std::vector<TransactionCoordinatorDocument> readAllCoordinatorDocs(OperationCont while (coordinatorDocsCursor->more()) { // TODO (SERVER-38307): Try/catch around parsing the document and skip the document if it // fails to parse. - auto nextDecision = TransactionCoordinatorDocument::parse(IDLParserErrorContext(""), + auto nextDecision = TransactionCoordinatorDocument::parse(IDLParserContext(""), coordinatorDocsCursor->next()); allCoordinatorDocs.push_back(nextDecision); } diff --git a/src/mongo/db/s/type_shard_collection.cpp b/src/mongo/db/s/type_shard_collection.cpp index 2628297e0d7..480eb393403 100644 --- a/src/mongo/db/s/type_shard_collection.cpp +++ b/src/mongo/db/s/type_shard_collection.cpp @@ -47,7 +47,7 @@ ShardCollectionType::ShardCollectionType(NamespaceString nss, unique) {} ShardCollectionType::ShardCollectionType(const BSONObj& obj) { - ShardCollectionTypeBase::parseProtected(IDLParserErrorContext("ShardCollectionType"), obj); + ShardCollectionTypeBase::parseProtected(IDLParserContext("ShardCollectionType"), obj); uassert(ErrorCodes::ShardKeyNotFound, str::stream() << "Empty shard key. Failed to parse: " << obj.toString(), diff --git a/src/mongo/db/s/type_shard_identity.cpp b/src/mongo/db/s/type_shard_identity.cpp index 673636f01b1..07519bf5637 100644 --- a/src/mongo/db/s/type_shard_identity.cpp +++ b/src/mongo/db/s/type_shard_identity.cpp @@ -49,7 +49,7 @@ StatusWith<ShardIdentityType> ShardIdentityType::fromShardIdentityDocument(const try { ShardIdentityType shardIdentity = - ShardIdentity::parse(IDLParserErrorContext("ShardIdentity"), shardIdentityBSON); + ShardIdentity::parse(IDLParserContext("ShardIdentity"), shardIdentityBSON); const auto& configsvrConnStr = shardIdentity.getConfigsvrConnectionString(); if (configsvrConnStr.type() != ConnectionString::ConnectionType::kReplicaSet) { diff --git a/src/mongo/db/s/user_writes_recoverable_critical_section_service.cpp b/src/mongo/db/s/user_writes_recoverable_critical_section_service.cpp index 4fa8a1d5bd2..be1cc7c2375 100644 --- a/src/mongo/db/s/user_writes_recoverable_critical_section_service.cpp +++ b/src/mongo/db/s/user_writes_recoverable_critical_section_service.cpp @@ -111,7 +111,7 @@ void acquireRecoverableCriticalSection(OperationContext* opCtx, const auto bsonObj = findRecoverableCriticalSectionDoc(opCtx, nss); if (!bsonObj.isEmpty()) { const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("AcquireUserWritesCS"), bsonObj); + IDLParserContext("AcquireUserWritesCS"), bsonObj); uassert(ErrorCodes::IllegalOperation, str::stream() << "Cannot acquire user writes critical section with different " @@ -225,7 +225,7 @@ void UserWritesRecoverableCriticalSectionService:: !bsonObj.isEmpty()); const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("PromoteUserWritesCS"), bsonObj); + IDLParserContext("PromoteUserWritesCS"), bsonObj); uassert(ErrorCodes::IllegalOperation, "Cannot promote user writes critical section to block user writes if sharded DDL " @@ -284,7 +284,7 @@ void UserWritesRecoverableCriticalSectionService:: } const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("DemoteUserWritesCS"), bsonObj); + IDLParserContext("DemoteUserWritesCS"), bsonObj); // If we are not currently blocking user writes, then we are done. if (!collCSDoc.getBlockUserWrites()) { @@ -332,7 +332,7 @@ void UserWritesRecoverableCriticalSectionService::releaseRecoverableCriticalSect } const auto collCSDoc = UserWriteBlockingCriticalSectionDocument::parse( - IDLParserErrorContext("ReleaseUserWritesCS"), bsonObj); + IDLParserContext("ReleaseUserWritesCS"), bsonObj); // Release the critical section by deleting the critical section document. The OpObserver // will release the in-memory CS when reacting to the delete event. diff --git a/src/mongo/db/serverless/shard_split_donor_op_observer.cpp b/src/mongo/db/serverless/shard_split_donor_op_observer.cpp index 9de2da2e33d..11056e2deba 100644 --- a/src/mongo/db/serverless/shard_split_donor_op_observer.cpp +++ b/src/mongo/db/serverless/shard_split_donor_op_observer.cpp @@ -50,8 +50,7 @@ const auto tenantIdsToDeleteDecoration = OperationContext::declareDecoration<boost::optional<std::vector<std::string>>>(); ShardSplitDonorDocument parseAndValidateDonorDocument(const BSONObj& doc) { - auto donorStateDoc = - ShardSplitDonorDocument::parse(IDLParserErrorContext("donorStateDoc"), doc); + auto donorStateDoc = ShardSplitDonorDocument::parse(IDLParserContext("donorStateDoc"), doc); const std::string errmsg = "Invalid donor state doc, {}: {}"; if (donorStateDoc.getExpireAt()) { diff --git a/src/mongo/db/serverless/shard_split_donor_service.cpp b/src/mongo/db/serverless/shard_split_donor_service.cpp index ae6317ff231..530fcb5e7ab 100644 --- a/src/mongo/db/serverless/shard_split_donor_service.cpp +++ b/src/mongo/db/serverless/shard_split_donor_service.cpp @@ -177,8 +177,7 @@ void ShardSplitDonorService::checkIfConflictsWithOtherInstances( OperationContext* opCtx, BSONObj initialState, const std::vector<const repl::PrimaryOnlyService::Instance*>& existingInstances) { - auto stateDoc = - ShardSplitDonorDocument::parse(IDLParserErrorContext("donorStateDoc"), initialState); + auto stateDoc = ShardSplitDonorDocument::parse(IDLParserContext("donorStateDoc"), initialState); for (auto& instance : existingInstances) { auto existingTypedInstance = @@ -200,7 +199,7 @@ std::shared_ptr<repl::PrimaryOnlyService::Instance> ShardSplitDonorService::cons return std::make_shared<DonorStateMachine>( _serviceContext, this, - ShardSplitDonorDocument::parse(IDLParserErrorContext("donorStateDoc"), initialState)); + ShardSplitDonorDocument::parse(IDLParserContext("donorStateDoc"), initialState)); } void ShardSplitDonorService::abortAllSplits(OperationContext* opCtx) { @@ -289,8 +288,7 @@ void ShardSplitDonorService::DonorStateMachine::tryForget() { void ShardSplitDonorService::DonorStateMachine::checkIfOptionsConflict( const BSONObj& stateDocBson) const { - auto stateDoc = - ShardSplitDonorDocument::parse(IDLParserErrorContext("donorStateDoc"), stateDocBson); + auto stateDoc = ShardSplitDonorDocument::parse(IDLParserContext("donorStateDoc"), stateDocBson); stdx::lock_guard<Latch> lg(_mutex); invariant(stateDoc.getId() == _stateDoc.getId()); diff --git a/src/mongo/db/serverless/shard_split_donor_service_test.cpp b/src/mongo/db/serverless/shard_split_donor_service_test.cpp index 85cc7d5f9f6..3395a9a563e 100644 --- a/src/mongo/db/serverless/shard_split_donor_service_test.cpp +++ b/src/mongo/db/serverless/shard_split_donor_service_test.cpp @@ -110,8 +110,7 @@ StatusWith<ShardSplitDonorDocument> getStateDocument(OperationContext* opCtx, } try { - return ShardSplitDonorDocument::parse(IDLParserErrorContext("shardSplitStateDocument"), - result); + return ShardSplitDonorDocument::parse(IDLParserContext("shardSplitStateDocument"), result); } catch (DBException& ex) { return ex.toStatus(str::stream() << "Invalid BSON found for matching document with shard split id: " diff --git a/src/mongo/db/session_catalog_mongod.cpp b/src/mongo/db/session_catalog_mongod.cpp index 0057d803814..4c91937f48f 100644 --- a/src/mongo/db/session_catalog_mongod.cpp +++ b/src/mongo/db/session_catalog_mongod.cpp @@ -456,8 +456,8 @@ void abortInProgressTransactions(OperationContext* opCtx) { LOGV2_DEBUG(21977, 3, "Aborting in-progress transactions on stepup."); } while (cursor->more()) { - auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("abort-in-progress-transactions"), cursor->next()); + auto txnRecord = SessionTxnRecord::parse(IDLParserContext("abort-in-progress-transactions"), + cursor->next()); opCtx->setLogicalSessionId(txnRecord.getSessionId()); opCtx->setTxnNumber(txnRecord.getTxnNum()); opCtx->setInMultiDocumentTransaction(); @@ -606,7 +606,7 @@ void MongoDSessionCatalog::observeDirectWriteToConfigTransactions(OperationConte const auto catalog = SessionCatalog::get(opCtx); const auto lsid = - LogicalSessionId::parse(IDLParserErrorContext("lsid"), singleSessionDoc["_id"].Obj()); + LogicalSessionId::parse(IDLParserContext("lsid"), singleSessionDoc["_id"].Obj()); catalog->scanSession(lsid, [&](const ObservableSession& session) { const auto participant = TransactionParticipant::get(session); uassert(ErrorCodes::PreparedTransactionInProgress, diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp index c88694ba120..b8be8cca3f2 100644 --- a/src/mongo/db/storage/storage_engine_impl.cpp +++ b/src/mongo/db/storage/storage_engine_impl.cpp @@ -499,7 +499,7 @@ bool StorageEngineImpl::_handleInternalIdent(OperationContext* opCtx, "failToParseResumeIndexInfo fail point is enabled"); } - resumeInfo = ResumeIndexInfo::parse(IDLParserErrorContext("ResumeIndexInfo"), doc); + resumeInfo = ResumeIndexInfo::parse(IDLParserContext("ResumeIndexInfo"), doc); } catch (const DBException& e) { LOGV2(4916300, "Failed to parse resumable index info", "error"_attr = e.toStatus()); diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp index ce2de3e9490..5d1910b7ffc 100644 --- a/src/mongo/db/transaction_participant.cpp +++ b/src/mongo/db/transaction_participant.cpp @@ -227,7 +227,7 @@ ActiveTransactionHistory fetchActiveTransactionHistory(OperationContext* opCtx, return boost::none; } return SessionTxnRecord::parse( - IDLParserErrorContext("parse latest txn record for session"), result); + IDLParserContext("parse latest txn record for session"), result); }); } (); @@ -359,8 +359,8 @@ TxnNumber fetchHighestTxnNumberWithInternalSessions(OperationContext* opCtx, while (cursor->more()) { const auto doc = cursor->next(); - const auto childLsid = LogicalSessionId::parse( - IDLParserErrorContext("LogicalSessionId"), doc.getObjectField("_id")); + const auto childLsid = LogicalSessionId::parse(IDLParserContext("LogicalSessionId"), + doc.getObjectField("_id")); invariant(!cursor->more()); // All config.transactions entries with the parentLsid field should have a txnNumber @@ -597,8 +597,8 @@ TransactionParticipant::getOldestActiveTimestamp(Timestamp stableTimestamp) { auto cursor = collection->getCursor(opCtx.get()); while (auto record = cursor->next()) { auto doc = record.get().data.toBson(); - auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("parse oldest active txn record"), doc); + auto txnRecord = + SessionTxnRecord::parse(IDLParserContext("parse oldest active txn record"), doc); if (txnRecord.getState() != DurableTxnStateEnum::kPrepared && txnRecord.getState() != DurableTxnStateEnum::kInProgress) { continue; @@ -3007,7 +3007,7 @@ void TransactionParticipant::Participant::_refreshActiveTransactionParticipantsF while (cursor->more()) { const auto doc = cursor->next(); const auto childLsid = LogicalSessionId::parse( - IDLParserErrorContext("LogicalSessionId"), doc.getObjectField("_id")); + IDLParserContext("LogicalSessionId"), doc.getObjectField("_id")); uassert(6202001, str::stream() << "Refresh expected the highest transaction number in the session " diff --git a/src/mongo/db/transaction_participant_retryable_writes_test.cpp b/src/mongo/db/transaction_participant_retryable_writes_test.cpp index 48679012051..708eb7df4db 100644 --- a/src/mongo/db/transaction_participant_retryable_writes_test.cpp +++ b/src/mongo/db/transaction_participant_retryable_writes_test.cpp @@ -279,7 +279,7 @@ protected: auto txnRecordObj = cursor->next(); auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("SessionEntryWrittenAtFirstWrite"), txnRecordObj); + IDLParserContext("SessionEntryWrittenAtFirstWrite"), txnRecordObj); ASSERT(!cursor->more()); ASSERT_EQ(session->getSessionId(), txnRecord.getSessionId()); ASSERT_EQ(txnNum, txnRecord.getTxnNum()); @@ -350,8 +350,8 @@ TEST_F(TransactionParticipantRetryableWritesTest, SessionEntryWrittenAtFirstWrit ASSERT(cursor); ASSERT(cursor->more()); - auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("SessionEntryWrittenAtFirstWrite"), cursor->next()); + auto txnRecord = SessionTxnRecord::parse(IDLParserContext("SessionEntryWrittenAtFirstWrite"), + cursor->next()); ASSERT(!cursor->more()); ASSERT_EQ(sessionId, txnRecord.getSessionId()); ASSERT_EQ(txnNum, txnRecord.getTxnNum()); @@ -377,8 +377,8 @@ TEST_F(TransactionParticipantRetryableWritesTest, ASSERT(cursor); ASSERT(cursor->more()); - auto txnRecord = SessionTxnRecord::parse( - IDLParserErrorContext("SessionEntryWrittenAtFirstWrite"), cursor->next()); + auto txnRecord = SessionTxnRecord::parse(IDLParserContext("SessionEntryWrittenAtFirstWrite"), + cursor->next()); ASSERT(!cursor->more()); ASSERT_EQ(sessionId, txnRecord.getSessionId()); ASSERT_EQ(200, txnRecord.getTxnNum()); diff --git a/src/mongo/dbtests/logical_sessions_tests.cpp b/src/mongo/dbtests/logical_sessions_tests.cpp index 28f1699e071..bf5e62466b3 100644 --- a/src/mongo/dbtests/logical_sessions_tests.cpp +++ b/src/mongo/dbtests/logical_sessions_tests.cpp @@ -69,7 +69,7 @@ StatusWith<LogicalSessionRecord> fetchRecord(OperationContext* opCtx, } try { - IDLParserErrorContext ctx("LogicalSessionRecord"); + IDLParserContext ctx("LogicalSessionRecord"); return LogicalSessionRecord::parse(ctx, cursor->next()); } catch (...) { return exceptionToStatus(); diff --git a/src/mongo/executor/remote_command_runner.h b/src/mongo/executor/remote_command_runner.h index b2da193c47f..59f8e805a38 100644 --- a/src/mongo/executor/remote_command_runner.h +++ b/src/mongo/executor/remote_command_runner.h @@ -80,7 +80,7 @@ SemiFuture<typename CommandType::Reply> doRequest(CommandType cmd, return std::move(resFuture) .then([&, exec = std::move(exec)](BSONObj r) { // TODO SERVER-67661: Make IDL reply types have string representation for logging - auto res = CommandType::Reply::parse(IDLParserErrorContext("RemoteCommandRunner"), r); + auto res = CommandType::Reply::parse(IDLParserContext("RemoteCommandRunner"), r); return res; }) .semi(); diff --git a/src/mongo/idl/idl_parser.cpp b/src/mongo/idl/idl_parser.cpp index 29a1d5163aa..0fbc02051e2 100644 --- a/src/mongo/idl/idl_parser.cpp +++ b/src/mongo/idl/idl_parser.cpp @@ -61,12 +61,11 @@ std::string toCommaDelimitedList(const std::vector<BSONType>& types) { } // namespace -constexpr StringData IDLParserErrorContext::kOpMsgDollarDBDefault; -constexpr StringData IDLParserErrorContext::kOpMsgDollarDB; +constexpr StringData IDLParserContext::kOpMsgDollarDBDefault; +constexpr StringData IDLParserContext::kOpMsgDollarDB; constexpr auto collectionlessAggregateCursorCol = "$cmd.aggregate"_sd; -bool IDLParserErrorContext::checkAndAssertTypeSlowPath(const BSONElement& element, - BSONType type) const { +bool IDLParserContext::checkAndAssertTypeSlowPath(const BSONElement& element, BSONType type) const { auto elementType = element.type(); // If the type is wrong, ignore Null and Undefined values @@ -81,8 +80,8 @@ bool IDLParserErrorContext::checkAndAssertTypeSlowPath(const BSONElement& elemen << "'"); } -bool IDLParserErrorContext::checkAndAssertBinDataTypeSlowPath(const BSONElement& element, - BinDataType type) const { +bool IDLParserContext::checkAndAssertBinDataTypeSlowPath(const BSONElement& element, + BinDataType type) const { bool isBinDataType = checkAndAssertType(element, BinData); if (!isBinDataType) { return false; @@ -99,8 +98,8 @@ bool IDLParserErrorContext::checkAndAssertBinDataTypeSlowPath(const BSONElement& return true; } -bool IDLParserErrorContext::checkAndAssertTypes(const BSONElement& element, - const std::vector<BSONType>& types) const { +bool IDLParserContext::checkAndAssertTypes(const BSONElement& element, + const std::vector<BSONType>& types) const { auto elementType = element.type(); auto pos = std::find(types.begin(), types.end(), elementType); @@ -117,11 +116,11 @@ bool IDLParserErrorContext::checkAndAssertTypes(const BSONElement& element, } -std::string IDLParserErrorContext::getElementPath(const BSONElement& element) const { +std::string IDLParserContext::getElementPath(const BSONElement& element) const { return getElementPath(element.fieldNameStringData()); } -std::string IDLParserErrorContext::getElementPath(StringData fieldName) const { +std::string IDLParserContext::getElementPath(StringData fieldName) const { if (_predecessor == nullptr) { str::stream builder; @@ -141,7 +140,7 @@ std::string IDLParserErrorContext::getElementPath(StringData fieldName) const { pieces.push(_currentField); - const IDLParserErrorContext* head = _predecessor; + const IDLParserContext* head = _predecessor; while (head) { pieces.push(head->_currentField); head = head->_predecessor; @@ -162,22 +161,22 @@ std::string IDLParserErrorContext::getElementPath(StringData fieldName) const { } } -void IDLParserErrorContext::throwDuplicateField(StringData fieldName) const { +void IDLParserContext::throwDuplicateField(StringData fieldName) const { std::string path = getElementPath(fieldName); uasserted(40413, str::stream() << "BSON field '" << path << "' is a duplicate field"); } -void IDLParserErrorContext::throwDuplicateField(const BSONElement& element) const { +void IDLParserContext::throwDuplicateField(const BSONElement& element) const { throwDuplicateField(element.fieldNameStringData()); } -void IDLParserErrorContext::throwMissingField(StringData fieldName) const { +void IDLParserContext::throwMissingField(StringData fieldName) const { std::string path = getElementPath(fieldName); uasserted(40414, str::stream() << "BSON field '" << path << "' is missing but a required field"); } -void IDLParserErrorContext::throwUnknownField(StringData fieldName) const { +void IDLParserContext::throwUnknownField(StringData fieldName) const { std::string path = getElementPath(fieldName); if (isMongocryptdArgument(fieldName)) { uasserted( @@ -190,15 +189,15 @@ void IDLParserErrorContext::throwUnknownField(StringData fieldName) const { uasserted(40415, str::stream() << "BSON field '" << path << "' is an unknown field."); } -void IDLParserErrorContext::throwBadArrayFieldNumberValue(StringData value) const { +void IDLParserContext::throwBadArrayFieldNumberValue(StringData value) const { std::string path = getElementPath(StringData()); uasserted(40422, str::stream() << "BSON array field '" << path << "' has an invalid value '" << value << "' for an array field name."); } -void IDLParserErrorContext::throwBadArrayFieldNumberSequence(std::uint32_t actualValue, - std::uint32_t expectedValue) const { +void IDLParserContext::throwBadArrayFieldNumberSequence(std::uint32_t actualValue, + std::uint32_t expectedValue) const { std::string path = getElementPath(StringData()); uasserted(40423, str::stream() << "BSON array field '" << path << "' has a non-sequential value '" @@ -206,22 +205,22 @@ void IDLParserErrorContext::throwBadArrayFieldNumberSequence(std::uint32_t actua << expectedValue << "'."); } -void IDLParserErrorContext::throwBadEnumValue(int enumValue) const { +void IDLParserContext::throwBadEnumValue(int enumValue) const { std::string path = getElementPath(StringData()); uasserted(ErrorCodes::BadValue, str::stream() << "Enumeration value '" << enumValue << "' for field '" << path << "' is not a valid value."); } -void IDLParserErrorContext::throwBadEnumValue(StringData enumValue) const { +void IDLParserContext::throwBadEnumValue(StringData enumValue) const { std::string path = getElementPath(StringData()); uasserted(ErrorCodes::BadValue, str::stream() << "Enumeration value '" << enumValue << "' for field '" << path << "' is not a valid value."); } -void IDLParserErrorContext::throwBadType(const BSONElement& element, - const std::vector<BSONType>& types) const { +void IDLParserContext::throwBadType(const BSONElement& element, + const std::vector<BSONType>& types) const { std::string path = getElementPath(element); std::string type_str = toCommaDelimitedList(types); uasserted(ErrorCodes::TypeMismatch, @@ -230,20 +229,20 @@ void IDLParserErrorContext::throwBadType(const BSONElement& element, << "']"); } -void IDLParserErrorContext::throwAPIStrictErrorIfApplicable(BSONElement field) const { +void IDLParserContext::throwAPIStrictErrorIfApplicable(BSONElement field) const { throwAPIStrictErrorIfApplicable(field.fieldNameStringData()); } -void IDLParserErrorContext::throwAPIStrictErrorIfApplicable(StringData fieldName) const { +void IDLParserContext::throwAPIStrictErrorIfApplicable(StringData fieldName) const { uassert(ErrorCodes::APIStrictError, str::stream() << "BSON field '" << getElementPath(fieldName) << "' is not allowed with apiStrict:true.", !_apiStrict); } -NamespaceString IDLParserErrorContext::parseNSCollectionRequired(const DatabaseName& dbName, - const BSONElement& element, - bool allowGlobalCollectionName) { +NamespaceString IDLParserContext::parseNSCollectionRequired(const DatabaseName& dbName, + const BSONElement& element, + bool allowGlobalCollectionName) { const bool isUUID = (element.canonicalType() == canonicalizeBSONType(mongo::BinData) && element.binDataType() == BinDataType::newUUID); uassert(ErrorCodes::BadValue, @@ -272,8 +271,8 @@ NamespaceString IDLParserErrorContext::parseNSCollectionRequired(const DatabaseN return nss; } -NamespaceStringOrUUID IDLParserErrorContext::parseNsOrUUID(const DatabaseName& dbName, - const BSONElement& element) { +NamespaceStringOrUUID IDLParserContext::parseNsOrUUID(const DatabaseName& dbName, + const BSONElement& element) { if (element.type() == BinData && element.binDataType() == BinDataType::newUUID) { return {dbName, uassertStatusOK(UUID::parse(element))}; } else { @@ -282,10 +281,9 @@ NamespaceStringOrUUID IDLParserErrorContext::parseNsOrUUID(const DatabaseName& d } } -void IDLParserErrorContext::appendGenericCommandArguments( - const BSONObj& commandPassthroughFields, - const std::vector<StringData>& knownFields, - BSONObjBuilder* builder) { +void IDLParserContext::appendGenericCommandArguments(const BSONObj& commandPassthroughFields, + const std::vector<StringData>& knownFields, + BSONObjBuilder* builder) { for (const auto& element : commandPassthroughFields) { diff --git a/src/mongo/idl/idl_parser.h b/src/mongo/idl/idl_parser.h index 3a534755bcb..d41122ce3bb 100644 --- a/src/mongo/idl/idl_parser.h +++ b/src/mongo/idl/idl_parser.h @@ -211,7 +211,7 @@ struct BasicOrderOps<boost::optional<T>> { } // namespace idl /** - * IDLParserErrorContext manages the current parser context for parsing BSON documents. + * IDLParserContext manages the current parser context for parsing BSON documents. * * The class stores the path to the current document to enable it provide more useful error * messages. The path is a dot delimited list of field names which is useful for nested struct @@ -220,12 +220,12 @@ struct BasicOrderOps<boost::optional<T>> { * This class is responsible for throwing all error messages the IDL generated parsers throw, * and provide utility methods like checking a BSON type or set of BSON types. */ -class IDLParserErrorContext { - IDLParserErrorContext(const IDLParserErrorContext&) = delete; - IDLParserErrorContext& operator=(const IDLParserErrorContext&) = delete; +class IDLParserContext { + IDLParserContext(const IDLParserContext&) = delete; + IDLParserContext& operator=(const IDLParserContext&) = delete; template <typename T> - friend void throwComparisonError(IDLParserErrorContext& ctxt, + friend void throwComparisonError(IDLParserContext& ctxt, StringData fieldName, StringData op, T actualValue, @@ -238,10 +238,10 @@ public: static constexpr auto kOpMsgDollarDB = "$db"_sd; static constexpr auto kOpMsgDollarDBDefault = "admin"_sd; - IDLParserErrorContext(StringData fieldName, bool apiStrict = false) + IDLParserContext(StringData fieldName, bool apiStrict = false) : _currentField(fieldName), _apiStrict(apiStrict), _predecessor(nullptr) {} - IDLParserErrorContext(StringData fieldName, const IDLParserErrorContext* predecessor) + IDLParserContext(StringData fieldName, const IDLParserContext* predecessor) : _currentField(fieldName), _predecessor(predecessor) {} /** @@ -390,18 +390,15 @@ private: // Pointer to a parent parser context. // This provides a singly linked list of parent pointers, and use to produce a full path to a // field with an error. - const IDLParserErrorContext* _predecessor; + const IDLParserContext* _predecessor; }; /** * Throw an error when BSON validation fails during parse. */ template <typename T> -void throwComparisonError(IDLParserErrorContext& ctxt, - StringData fieldName, - StringData op, - T actualValue, - T expectedValue) { +void throwComparisonError( + IDLParserContext& ctxt, StringData fieldName, StringData op, T actualValue, T expectedValue) { std::string path = ctxt.getElementPath(fieldName); throwComparisonError(path, op, actualValue, expectedValue); } diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp index 70d949c0636..a6422a8e4ea 100644 --- a/src/mongo/idl/idl_test.cpp +++ b/src/mongo/idl/idl_test.cpp @@ -233,7 +233,7 @@ TEST(IDLOneTypeTests, TestLoopbackTest) { // Test we compare an object with optional BSONObjs correctly TEST(IDLOneTypeTests, TestOptionalObjectTest) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testValue = BSON("Hello" << "World"); @@ -269,7 +269,7 @@ TEST(IDLOneTypeTests, TestOptionalObjectTest) { // mismatch. template <typename ParserT, BSONType Parser_bson_type, typename TestT, BSONType Test_bson_type> void TestParse(TestT test_value) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("value" << test_value); @@ -347,7 +347,7 @@ TEST(IDLOneTypeTests, TestSafeInt64) { // Mixed: test a type that accepts NamespaceString TEST(IDLOneTypeTests, TestNamespaceString) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(One_namespacestring::kValueFieldName << "foo.bar"); @@ -441,7 +441,7 @@ TEST(IDLOneTypeTests, TestBase64StringNegative) { // Postive: Test any type TEST(IDLOneTypeTests, TestAnyType) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: string field { @@ -471,7 +471,7 @@ TEST(IDLOneTypeTests, TestAnyType) { // Postive: Test object type TEST(IDLOneTypeTests, TestObjectType) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: object { @@ -490,7 +490,7 @@ TEST(IDLOneTypeTests, TestObjectType) { // Negative: Test object type TEST(IDLOneTypeTests, TestObjectTypeNegative) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative: string field { @@ -517,7 +517,7 @@ constexpr bool isVector = IsVector<T>::value; // We don't generate comparison operators like "==" for variants, so test only for BSON equality. template <typename ParserT, typename TestT, BSONType Test_bson_type> void TestLoopbackVariant(TestT test_value) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); BSONObjBuilder bob; if constexpr (idl::hasBSONSerialize<TestT>) { @@ -598,7 +598,7 @@ TEST(IDLVariantTests, TestVariantSafeInt) { TestLoopbackVariant<One_variant_safeInt, int, NumberInt>(1); // safeInt accepts all numbers, but always deserializes and serializes as int32. - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); ASSERT_EQ(stdx::get<std::int32_t>( One_variant_safeInt::parse(ctxt, BSON("value" << Decimal128(1))).getValue()), 1); @@ -619,7 +619,7 @@ TEST(IDLVariantTests, TestVariantSafeIntArray) { TestLoopbackVariant<One_variant_safeInt_array, int32vec, Array>({1, 2}); // Use ASSERT instead of ASSERT_EQ to avoid operator<< - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); ASSERT(stdx::get<int32vec>( One_variant_safeInt_array::parse(ctxt, BSON("value" << BSON_ARRAY(Decimal128(1)))) .getValue()) == int32vec{1}); @@ -736,7 +736,7 @@ TEST(IDLVariantTests, TestTwoVariants) { } TEST(IDLVariantTests, TestChainedStructVariant) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { auto obj = BSON("value" << "x" @@ -810,7 +810,7 @@ TEST(IDLVariantTests, TestChainedStructVariant) { } TEST(IDLVariantTests, TestChainedStructVariantInline) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { auto obj = BSON("value" << "x" @@ -881,7 +881,7 @@ TEST(IDLVariantTests, TestChainedStructVariantInline) { } TEST(IDLVariantTests, TestChainedStructVariantStruct) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { auto obj = BSON("value" << 1 << "field1" << "y"); @@ -928,7 +928,7 @@ TEST(IDLVariantTests, TestChainedStructVariantStruct) { } TEST(IDLVariantTests, TestChainedStructVariantStructInline) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { auto obj = BSON("value" << 1 << "field1" << "y"); @@ -978,7 +978,7 @@ TEST(IDLVariantTests, TestChainedStructVariantStructInline) { // Negative: strict, ensure extra fields fail // Negative: strict, duplicate fields TEST(IDLStructTests, TestStrictStruct) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Just 3 required fields { @@ -1017,7 +1017,7 @@ TEST(IDLStructTests, TestStrictStruct) { // Positive: non-strict, ensure extra fields work // Negative: non-strict, duplicate fields TEST(IDLStructTests, TestNonStrictStruct) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Just 3 required fields { @@ -1072,7 +1072,7 @@ TEST(IDLStructTests, TestNonStrictStruct) { } TEST(IDLStructTests, WriteConcernTest) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Numeric w value { auto writeConcernDoc = BSON("w" << 1 << "j" << true << "wtimeout" << 5000); @@ -1109,7 +1109,7 @@ TEST(IDLStructTests, WriteConcernTest) { TEST(IDLStructTests, TestValidator) { // Parser should assert that the values are equal. - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto objToParse = BSON("first" << 1 << "second" << 2); ASSERT_THROWS_CODE(StructWithValidator::parse(ctxt, objToParse), AssertionException, 6253512); @@ -1120,7 +1120,7 @@ TEST(IDLStructTests, TestValidator) { /// Struct default comparison tests TEST(IDLCompareTests, TestAllFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: equality works { @@ -1160,7 +1160,7 @@ TEST(IDLCompareTests, TestAllFields) { /// Struct partial comparison tests TEST(IDLCompareTests, TestSomeFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: partial equality works when field 2 is different { @@ -1217,7 +1217,7 @@ TEST(IDLCompareTests, TestSomeFields) { /// Field tests // Positive: check ignored field is ignored TEST(IDLFieldTests, TestStrictStructIgnoredField) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test ignored field is ignored { @@ -1234,7 +1234,7 @@ TEST(IDLFieldTests, TestStrictStructIgnoredField) { // Negative: check duplicate ignored fields fail TEST(IDLFieldTests, TestStrictDuplicateIgnoredFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative: Test duplicate ignored fields fail { @@ -1275,7 +1275,7 @@ TEST(IDLFieldTests, TestStrictDuplicateIgnoredFields) { // Mixed: struct strict, and ignored field works TEST(IDLFieldTests, TestDefaultFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); TEST_DEFAULT_VALUES(V_string, "a default", "foo"); TEST_DEFAULT_VALUES(V_int, 42, 3); @@ -1288,7 +1288,7 @@ TEST(IDLFieldTests, TestDefaultFields) { // Positive: struct strict, and optional field works TEST(IDLFieldTests, TestOptionalFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document with only string field { @@ -1342,7 +1342,7 @@ TEST(IDLFieldTests, TestOptionalFields) { } TEST(IDLFieldTests, TestAlwaysSerializeFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << "Foo" @@ -1373,7 +1373,7 @@ TEST(IDLFieldTests, TestAlwaysSerializeFields) { template <typename TestT> void TestWeakType(TestT test_value) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << test_value << "field2" << test_value << "field3" << test_value << "field4" << test_value << "field5" << test_value); auto testStruct = Optional_field::parse(ctxt, testDoc); @@ -1395,7 +1395,7 @@ TEST(IDLFieldTests, TestOptionalFieldsWithNullAndUndefined) { // Positive: Test a nested struct TEST(IDLNestedStruct, TestDuplicateTypes) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document @@ -1453,7 +1453,7 @@ TEST(IDLNestedStruct, TestDuplicateTypes) { // Positive: Arrays of simple types TEST(IDLArrayTests, TestSimpleArrays) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document uint8_t array1[] = {1, 2, 3}; @@ -1523,7 +1523,7 @@ TEST(IDLArrayTests, TestSimpleArrays) { // Positive: Optional Arrays TEST(IDLArrayTests, TestSimpleOptionalArrays) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document auto testDoc = BSON("field1" << BSON_ARRAY("Foo" @@ -1577,7 +1577,7 @@ TEST(IDLArrayTests, TestSimpleOptionalArrays) { // Negative: Test mixed type arrays TEST(IDLArrayTests, TestBadArrays) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative: Test not an array { @@ -1596,7 +1596,7 @@ TEST(IDLArrayTests, TestBadArrays) { // Negative: Test arrays with good field names but made with BSONObjBuilder::subobjStart TEST(IDLArrayTests, TestGoodArraysWithObjectType) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { BSONObjBuilder builder; @@ -1613,7 +1613,7 @@ TEST(IDLArrayTests, TestGoodArraysWithObjectType) { // Positive: Test arrays with good field names but made with BSONObjBuilder::subarrayStart TEST(IDLArrayTests, TestGoodArraysWithArrayType) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { BSONObjBuilder builder; @@ -1631,7 +1631,7 @@ TEST(IDLArrayTests, TestGoodArraysWithArrayType) { // Negative: Test arrays with bad field names TEST(IDLArrayTests, TestBadArrayFieldNames) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative: string fields { @@ -1675,7 +1675,7 @@ TEST(IDLArrayTests, TestBadArrayFieldNames) { // Postitive: Test arrays with complex types TEST(IDLArrayTests, TestArraysOfComplexTypes) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document auto testDoc = BSON("field1" << BSON_ARRAY(1 << 2 << 3) << "field2" @@ -1738,7 +1738,7 @@ TEST(IDLArrayTests, TestArraysOfComplexTypes) { template <typename ParserT, BinDataType bindata_type> void TestBinDataVector() { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document with only a generic bindata field uint8_t testData[] = {1, 2, 3}; @@ -1786,7 +1786,7 @@ TEST(IDLBinData, TestFunction) { template <typename ParserT, BinDataType bindata_type> void TestBinDataArray() { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Test document with only a generic bindata field uint8_t testData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; @@ -1829,7 +1829,7 @@ TEST(IDLBinData, TestMD5) { // Negative: Test document with a incorrectly size md5 field { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); uint8_t testData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; auto testDoc = BSON("value" << BSONBinData(testData, 15, MD5Type)); @@ -1841,7 +1841,7 @@ TEST(IDLBinData, TestMD5) { // mismatch. template <typename ParserT, BinDataType Parser_bindata_type, BinDataType Test_bindata_type> void TestBinDataParse() { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); uint8_t testData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; auto testDoc = BSON("value" << BSONBinData(testData, 16, Test_bindata_type)); @@ -1875,7 +1875,7 @@ TEST(IDLBinData, TestParse) { // Mixed: test a type that accepts a custom bindata type TEST(IDLBinData, TestCustomType) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); uint8_t testData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; auto testDoc = BSON("value" << BSONBinData(testData, 14, BinDataGeneral)); @@ -1911,7 +1911,7 @@ TEST(IDLBinData, TestCustomType) { // Positive: test a type that accepts a custom UUID type TEST(IDLBinData, TestUUIDclass) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto uuid = UUID::gen(); auto testDoc = BSON("value" << uuid); @@ -1949,7 +1949,7 @@ TEST(IDLBinData, TestUUIDclass) { */ class ClassDerivedFromStruct : public DerivedBaseStruct { public: - static ClassDerivedFromStruct parseFromBSON(const IDLParserErrorContext& ctxt, + static ClassDerivedFromStruct parseFromBSON(const IDLParserContext& ctxt, const BSONObj& bsonObject) { ClassDerivedFromStruct o; o.parseProtected(ctxt, bsonObject); @@ -1971,7 +1971,7 @@ private: // Positive: demonstrate a class derived from an IDL parser. TEST(IDLCustomType, TestDerivedParser) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << 3 << "field2" << 5); @@ -2009,7 +2009,7 @@ TEST(IDLCustomType, TestDerivedParser) { // Positive: demonstrate a class struct chained types TEST(IDLChainedType, TestChainedType) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << "abc" @@ -2052,7 +2052,7 @@ TEST(IDLChainedType, TestChainedType) { // Positive: demonstrate a struct with chained types ignoring extra fields TEST(IDLChainedType, TestExtraFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << "abc" @@ -2066,7 +2066,7 @@ TEST(IDLChainedType, TestExtraFields) { // Negative: demonstrate a struct with chained types with duplicate fields TEST(IDLChainedType, TestDuplicateFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << "abc" @@ -2078,7 +2078,7 @@ TEST(IDLChainedType, TestDuplicateFields) { // Positive: demonstrate a struct with chained structs TEST(IDLChainedType, TestChainedStruct) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("anyField" << 123.456 << "objectField" << BSON("random" @@ -2114,7 +2114,7 @@ TEST(IDLChainedType, TestChainedStruct) { // Negative: demonstrate a struct with chained structs and extra fields TEST(IDLChainedType, TestChainedStructWithExtraFields) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Extra field { @@ -2167,7 +2167,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) { // Positive: demonstrate a struct with chained structs and types TEST(IDLChainedType, TestChainedMixedStruct) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << "abc" @@ -2218,7 +2218,7 @@ TEST(IDLChainedType, TestChainedMixedStruct) { // Positive: demonstrate a class derived from an IDL parser. TEST(IDLEnum, TestEnum) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("field1" << 2 << "field2" << "zero"); @@ -2264,7 +2264,7 @@ TEST(IDLEnum, TestEnum) { // Negative: test bad values TEST(IDLEnum, TestIntEnumNegative) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Test string { @@ -2287,7 +2287,7 @@ TEST(IDLEnum, TestIntEnumNegative) { } TEST(IDLEnum, TestStringEnumNegative) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Test int { @@ -2332,7 +2332,7 @@ OpMsgRequest makeOMRWithTenant(BSONObj obj, TenantId tenant) { // Positive: demonstrate a command with concatenate with db TEST(IDLCommand, TestConcatentateWithDb) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(BasicConcatenateWithDbCommand::kCommandName << "coll1" << "field1" << 3 << "field2" @@ -2377,7 +2377,7 @@ TEST(IDLCommand, TestConcatentateWithDb) { } TEST(IDLCommand, TestConcatentateWithDb_WithTenant) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); const auto kTenantId = TenantId(OID::gen()); @@ -2399,7 +2399,7 @@ TEST(IDLCommand, TestConcatentateWithDb_WithTenant) { } TEST(IDLCommand, TestConcatentateWithDbSymbol) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Postive - symbol??? { @@ -2415,7 +2415,7 @@ TEST(IDLCommand, TestConcatentateWithDbSymbol) { TEST(IDLCommand, TestConcatentateWithDbNegative) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative - duplicate namespace field { @@ -2463,7 +2463,7 @@ TEST(IDLCommand, TestConcatentateWithDbNegative) { // Positive: demonstrate a command with concatenate with db or uuid - test NSS TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestNSS) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(BasicConcatenateWithDbOrUUIDCommand::kCommandName << "coll1" @@ -2509,7 +2509,7 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestNSS) { } TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestNSS_WithTenant) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSONObjBuilder{} .append(BasicConcatenateWithDbOrUUIDCommand::kCommandName, "coll1") @@ -2532,7 +2532,7 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestNSS_WithTenant) { // Positive: demonstrate a command with concatenate with db or uuid - test UUID TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestUUID) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); UUID uuid = UUID::gen(); @@ -2578,7 +2578,7 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestUUID) { } TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestUUID_WithTenant) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); UUID uuid = UUID::gen(); @@ -2603,7 +2603,7 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestUUID_WithTenant) { TEST(IDLCommand, TestConcatentateWithDbOrUUIDNegative) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative - duplicate namespace field { @@ -2653,7 +2653,7 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUIDNegative) { // Positive: demonstrate a command with concatenate with db TEST(IDLCommand, TestIgnore) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("BasicIgnoredCommand" << 1 << "field1" << 3 << "field2" << "five"); @@ -2685,7 +2685,7 @@ TEST(IDLCommand, TestIgnore) { TEST(IDLCommand, TestIgnoredNegative) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative - duplicate namespace field { @@ -2713,7 +2713,7 @@ TEST(IDLCommand, TestIgnoredNegative) { // We don't generate comparison operators like "==" for variants, so test only for BSON equality. template <typename CommandT, typename TestT, BSONType Test_bson_type> void TestLoopbackCommandTypeVariant(TestT test_value) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); BSONObjBuilder bob; if constexpr (idl::hasBSONSerialize<TestT>) { @@ -2766,7 +2766,7 @@ TEST(IDLCommand, TestCommandTypeVariant) { } TEST(IDLDocSequence, TestBasic) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testTempDoc = BSON("DocSequenceCommand" << "coll1" @@ -2841,7 +2841,7 @@ TEST(IDLDocSequence, TestBasic) { // Negative: Test a OpMsgRequest read without $db TEST(IDLDocSequence, TestMissingDB) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testTempDoc = BSON("DocSequenceCommand" << "coll1" @@ -2861,7 +2861,7 @@ TEST(IDLDocSequence, TestMissingDB) { // Positive: Test a command read and written to OpMsgRequest with content in DocumentSequence works template <typename TestT> void TestDocSequence(StringData name) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testTempDoc = BSON(name << "coll1" << "field1" << 3 << "field2" @@ -2900,7 +2900,7 @@ TEST(IDLDocSequence, TestDocSequence) { // Negative: Bad Doc Sequences template <typename TestT> void TestBadDocSequences(StringData name, bool extraFieldAllowed) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testTempDoc = BSON(name << "coll1" << "field1" << 3 << "field2" @@ -2967,7 +2967,7 @@ TEST(IDLDocSequence, TestBadDocSequences) { // Negative: Duplicate field across body and document sequence template <typename TestT> void TestDuplicateDocSequences(StringData name) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative: Duplicate fields in doc sequence and body { @@ -3018,7 +3018,7 @@ TEST(IDLDocSequence, TestDuplicateDocSequences) { // Positive: Test empty document sequence TEST(IDLDocSequence, TestEmptySequence) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Negative: Duplicate fields in doc sequence and body { @@ -3058,7 +3058,7 @@ TEST(IDLDocSequence, TestEmptySequence) { // Positive: Test all the OpMsg well known fields are ignored TEST(IDLDocSequence, TestWellKnownFieldsAreIgnored) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto knownFields = {"$audit", "$client", @@ -3105,7 +3105,7 @@ TEST(IDLDocSequence, TestWellKnownFieldsAreIgnored) { // Positive: Test all the OpMsg well known fields are passed through except $db. TEST(IDLDocSequence, TestWellKnownFieldsPassthrough) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto knownFields = {"$audit", "$client", @@ -3147,7 +3147,7 @@ TEST(IDLDocSequence, TestWellKnownFieldsPassthrough) { // Postive: Extra Fields in non-strict parser TEST(IDLDocSequence, TestNonStrict) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); // Positive: Extra field in document sequence { @@ -3193,7 +3193,7 @@ TEST(IDLDocSequence, TestNonStrict) { // Postive: Test a Command known field does not propagate from passthrough to the final BSON if it // is included as a field in the command. TEST(IDLCommand, TestKnownFieldDuplicate) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testPassthrough = BSON("$db" << "foo" @@ -3238,7 +3238,7 @@ TEST(IDLCommand, TestKnownFieldDuplicate) { // Positive: Test an inline nested chain struct works TEST(IDLChainedStruct, TestInline) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON("stringField" << "bar" @@ -3316,7 +3316,7 @@ TEST(IDLValidatedField, Int_basic_ranges) { std::int32_t nonpos, std::int32_t byte_range, std::int32_t int_range) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("positive_int" << pos << "negative_int" << neg << "non_negative_int" << nonneg << "non_positive_int" << nonpos << "byte_range_int" << byte_range << "range_int" << int_range); @@ -3336,7 +3336,7 @@ TEST(IDLValidatedField, Int_basic_ranges) { std::int32_t nonpos, std::int32_t byte_range, std::int32_t int_range) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("positive_int" << pos << "negative_int" << neg << "non_negative_int" << nonneg << "non_positive_int" << nonpos << "byte_range_int" << byte_range << "range_int" << int_range); @@ -3386,7 +3386,7 @@ TEST(IDLValidatedField, Double_basic_ranges) { // Positive case parsing. const auto tryPass = [](double pos, double neg, double nonneg, double nonpos, double double_range) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("positive_double" << pos << "negative_double" << neg << "non_negative_double" << nonneg << "non_positive_double" << nonpos << "range_double" << double_range); @@ -3401,7 +3401,7 @@ TEST(IDLValidatedField, Double_basic_ranges) { // Negative case parsing. const auto tryFail = [](double pos, double neg, double nonneg, double nonpos, double double_range) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("positive_double" << pos << "negative_double" << neg << "non_negative_double" << nonneg << "non_positive_double" << nonpos << "range_double" << double_range); @@ -3440,7 +3440,7 @@ TEST(IDLValidatedField, Callback_validators) { // Positive case parsing. const auto tryPass = [](std::int32_t int_even, double double_nearly_int, StringData string_starts_with_x) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("int_even" << int_even << "double_nearly_int" << double_nearly_int << "string_starts_with_x" << string_starts_with_x); auto obj = Callback_validators::parse(ctxt, doc); @@ -3452,7 +3452,7 @@ TEST(IDLValidatedField, Callback_validators) { // Negative case parsing. const auto tryFail = [](std::int32_t int_even, double double_nearly_int, StringData string_starts_with_x) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("int_even" << int_even << "double_nearly_int" << double_nearly_int << "string_starts_with_x" << string_starts_with_x); ASSERT_THROWS(Callback_validators::parse(ctxt, doc), AssertionException); @@ -3476,7 +3476,7 @@ TEST(IDLValidatedField, Callback_validators) { TEST(IDLValidatedArray, IntArrayValidation) { const auto tryPass = [](std::vector<std::int32_t> int_even) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("int_even" << int_even); auto obj = Int_array_validators::parse(ctxt, doc); @@ -3491,7 +3491,7 @@ TEST(IDLValidatedArray, IntArrayValidation) { tryPass({344}); const auto tryFail = [](std::vector<std::int32_t> int_uneven) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("int_even" << int_uneven); ASSERT_THROWS(Int_array_validators::parse(ctxt, doc), AssertionException); }; @@ -3506,7 +3506,7 @@ TEST(IDLValidatedArray, IntArrayValidation) { TEST(IDLValidatedArray, StringArrayValidation) { const auto tryPass = [](std::vector<std::string> valid) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("caps_strings" << valid); auto obj = String_array_validators::parse(ctxt, doc); @@ -3521,7 +3521,7 @@ TEST(IDLValidatedArray, StringArrayValidation) { tryPass({"ABC", "DEF", "XYZ"}); const auto tryFail = [](std::vector<std::string> invalid) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto doc = BSON("caps_strings" << invalid); ASSERT_THROWS(String_array_validators::parse(ctxt, doc), AssertionException); }; @@ -3535,7 +3535,7 @@ TEST(IDLValidatedArray, StringArrayValidation) { // Positive: verify a command a string arg TEST(IDLTypeCommand, TestString) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(CommandTypeStringCommand::kCommandName << "foo" << "field1" << 3 << "$db" @@ -3577,7 +3577,7 @@ TEST(IDLTypeCommand, TestString) { // Positive: verify a command can take an array of object TEST(IDLTypeCommand, TestArrayObject) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(CommandTypeArrayObjectCommand::kCommandName << BSON_ARRAY(BSON("sample" << "doc")) @@ -3606,7 +3606,7 @@ TEST(IDLTypeCommand, TestArrayObject) { // Positive: verify a command can take a struct TEST(IDLTypeCommand, TestStruct) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(CommandTypeStructCommand::kCommandName << BSON("value" << "sample") @@ -3642,7 +3642,7 @@ TEST(IDLTypeCommand, TestStruct) { // Positive: verify a command can take an array of structs TEST(IDLTypeCommand, TestStructArray) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(CommandTypeArrayStructCommand::kCommandName << BSON_ARRAY(BSON("value" << "sample")) @@ -3672,7 +3672,7 @@ TEST(IDLTypeCommand, TestStructArray) { // Positive: verify a command a string arg and alternate C++ name TEST(IDLTypeCommand, TestUnderscoreCommand) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(WellNamedCommand::kCommandName << "foo" << "field1" << 3 << "$db" @@ -3714,7 +3714,7 @@ TEST(IDLTypeCommand, TestUnderscoreCommand) { TEST(IDLTypeCommand, TestErrorReplyStruct) { // Correctly parse all required fields. { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto errorDoc = BSON("ok" << 0.0 << "code" << 123456 << "codeName" << "blah blah" @@ -3728,7 +3728,7 @@ TEST(IDLTypeCommand, TestErrorReplyStruct) { } // Non-strictness: ensure we parse even if input has extra fields. { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto errorDoc = BSON("a" << "b" @@ -3745,7 +3745,7 @@ TEST(IDLTypeCommand, TestErrorReplyStruct) { } // Ensure that we fail to parse if any required fields are missing. { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto missingOk = BSON("code" << 123456 << "codeName" << "blah blah" @@ -3767,7 +3767,7 @@ TEST(IDLTypeCommand, TestErrorReplyStruct) { } TEST(IDLTypeCommand, TestCommandWithIDLAnyTypeField) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); std::vector<BSONObj> differentTypeObjs = { BSON(CommandWithAnyTypeMember::kCommandName << 1 << "anyTypeField" << "string literal" @@ -3800,7 +3800,7 @@ TEST(IDLTypeCommand, TestCommandWithIDLAnyTypeField) { } TEST(IDLCommand, BasicNamespaceConstGetterCommand_TestNonConstGetterGeneration) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); const auto uuid = UUID::gen(); auto testDoc = BSON(BasicNamespaceConstGetterCommand::kCommandName << uuid << "field1" << 3 << "$db" @@ -3839,7 +3839,7 @@ TEST(IDLCommand, BasicNamespaceConstGetterCommand_TestNonConstGetterGeneration) } TEST(IDLTypeCommand, TestCommandWithIDLAnyTypeOwnedField) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto parsed = CommandWithAnyTypeOwnedMember::parse( ctxt, @@ -3897,7 +3897,7 @@ TEST(IDLTypeCommand, TestCommandWithIDLAnyTypeOwnedField) { } TEST(IDLCommand, TestCommandTypeNamespaceCommand_WithTenant) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSON(CommandTypeNamespaceCommand::kCommandName << "db.coll1" << "field1" << 3 << "$db" @@ -3915,7 +3915,7 @@ TEST(IDLCommand, TestCommandTypeNamespaceCommand_WithTenant) { } TEST(IDLTypeCommand, TestCommandWithNamespaceMember_WithTenant) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); auto testDoc = BSONObjBuilder{} .append("CommandWithNamespaceMember", 1) @@ -3985,7 +3985,7 @@ TEST(IDLAccessCheck, TestComplexAccessCheck) { } TEST(IDLFieldTests, TestOptionalBoolField) { - IDLParserErrorContext ctxt("root"); + IDLParserContext ctxt("root"); { auto testDoc = BSON("optBoolField" << true); diff --git a/src/mongo/rpc/metadata/impersonated_user_metadata.cpp b/src/mongo/rpc/metadata/impersonated_user_metadata.cpp index 63d0d4f7837..0e8e59bde6e 100644 --- a/src/mongo/rpc/metadata/impersonated_user_metadata.cpp +++ b/src/mongo/rpc/metadata/impersonated_user_metadata.cpp @@ -55,7 +55,7 @@ void readImpersonatedUserMetadata(const BSONElement& elem, OperationContext* opC // Always reset the current impersonation data to boost::none. MaybeImpersonatedUserMetadata newData; if (elem.type() == Object) { - IDLParserErrorContext errCtx(kImpersonationMetadataSectionName); + IDLParserContext errCtx(kImpersonationMetadataSectionName); auto data = ImpersonatedUserMetadata::parse(errCtx, elem.embeddedObject()); uassert(ErrorCodes::BadValue, diff --git a/src/mongo/rpc/reply_builder_interface.cpp b/src/mongo/rpc/reply_builder_interface.cpp index 809d23f7deb..e2c3a9e579f 100644 --- a/src/mongo/rpc/reply_builder_interface.cpp +++ b/src/mongo/rpc/reply_builder_interface.cpp @@ -80,7 +80,7 @@ BSONObj augmentReplyWithStatus(const Status& status, BSONObj reply) { // construct an invalid error reply. if (getTestCommandsEnabled()) { try { - ErrorReply::parse(IDLParserErrorContext("augmentReplyWithStatus"), bob.asTempObj()); + ErrorReply::parse(IDLParserContext("augmentReplyWithStatus"), bob.asTempObj()); } catch (const DBException&) { invariant(false, "invalid error-response to a command constructed in " diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp index 5941d8b3499..0e3e603a269 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp @@ -377,7 +377,7 @@ std::vector<DatabaseType> ShardingCatalogClientImpl::getAllDBs(OperationContext* std::vector<DatabaseType> databases; databases.reserve(dbs.size()); for (const BSONObj& doc : dbs) { - databases.emplace_back(DatabaseType::parse(IDLParserErrorContext("DatabaseType"), doc)); + databases.emplace_back(DatabaseType::parse(IDLParserContext("DatabaseType"), doc)); } return databases; @@ -409,8 +409,8 @@ StatusWith<repl::OpTimeWith<DatabaseType>> ShardingCatalogClientImpl::_fetchData invariant(docsWithOpTime.value.size() == 1); try { - auto db = DatabaseType::parse(IDLParserErrorContext("DatabaseType"), - docsWithOpTime.value.front()); + auto db = + DatabaseType::parse(IDLParserContext("DatabaseType"), docsWithOpTime.value.front()); return repl::OpTimeWith<DatabaseType>(db, docsWithOpTime.opTime); } catch (const DBException& e) { return e.toStatus("Failed to parse DatabaseType"); @@ -1106,7 +1106,7 @@ StatusWith<std::vector<KeysCollectionDocument>> ShardingCatalogClientImpl::getNe keys.reserve(keyDocs.size()); for (auto&& keyDoc : keyDocs) { try { - keys.push_back(KeysCollectionDocument::parse(IDLParserErrorContext("keyDoc"), keyDoc)); + keys.push_back(KeysCollectionDocument::parse(IDLParserContext("keyDoc"), keyDoc)); } catch (...) { return exceptionToStatus(); } diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp index 7ed4cc739cc..3ad4047d3c1 100644 --- a/src/mongo/s/catalog/type_chunk.cpp +++ b/src/mongo/s/catalog/type_chunk.cpp @@ -193,7 +193,7 @@ StatusWith<std::vector<ChunkHistory>> ChunkHistory::fromBSON(const BSONArray& so for (const auto& arrayElement : source) { if (arrayElement.type() == Object) { - IDLParserErrorContext tempContext("chunk history array"); + IDLParserContext tempContext("chunk history array"); values.emplace_back(ChunkHistoryBase::parse(tempContext, arrayElement.Obj())); } else { return {ErrorCodes::BadValue, diff --git a/src/mongo/s/catalog/type_collection.cpp b/src/mongo/s/catalog/type_collection.cpp index 5cc64eca8b5..86854f7a257 100644 --- a/src/mongo/s/catalog/type_collection.cpp +++ b/src/mongo/s/catalog/type_collection.cpp @@ -59,7 +59,7 @@ CollectionType::CollectionType(NamespaceString nss, } CollectionType::CollectionType(const BSONObj& obj) { - CollectionType::parseProtected(IDLParserErrorContext("CollectionType"), obj); + CollectionType::parseProtected(IDLParserContext("CollectionType"), obj); invariant(getTimestamp() != Timestamp(0, 0)); uassert(ErrorCodes::BadValue, str::stream() << "Invalid namespace " << getNss(), diff --git a/src/mongo/s/catalog/type_database_test.cpp b/src/mongo/s/catalog/type_database_test.cpp index 73197980f55..f81016bae22 100644 --- a/src/mongo/s/catalog/type_database_test.cpp +++ b/src/mongo/s/catalog/type_database_test.cpp @@ -42,7 +42,7 @@ using std::string; TEST(DatabaseType, Empty) { // Constructing from empty BSON must fails - ASSERT_THROWS(DatabaseType::parse(IDLParserErrorContext("DatabaseType"), BSONObj()), + ASSERT_THROWS(DatabaseType::parse(IDLParserContext("DatabaseType"), BSONObj()), AssertionException); } @@ -55,7 +55,7 @@ TEST(DatabaseType, Basic) { << DatabaseType::kShardedFieldName << true << DatabaseType::kVersionFieldName << BSON("uuid" << uuid << "lastMod" << 0 << "timestamp" << timestamp)); - const auto db = DatabaseType::parse(IDLParserErrorContext("DatabaseType"), dbObj); + const auto db = DatabaseType::parse(IDLParserContext("DatabaseType"), dbObj); ASSERT_EQUALS(db.getName(), "mydb"); ASSERT_EQUALS(db.getPrimary(), "shard"); ASSERT_TRUE(db.getSharded()); @@ -66,15 +66,13 @@ TEST(DatabaseType, Basic) { TEST(DatabaseType, BadType) { // Cosntructing from an BSON object with a malformed database must fails const auto dbObj = BSON(DatabaseType::kNameFieldName << 0); - ASSERT_THROWS(DatabaseType::parse(IDLParserErrorContext("DatabaseType"), dbObj), - AssertionException); + ASSERT_THROWS(DatabaseType::parse(IDLParserContext("DatabaseType"), dbObj), AssertionException); } TEST(DatabaseType, MissingRequired) { // Cosntructing from an BSON object without all the required fields must fails const auto dbObj = BSON(DatabaseType::kNameFieldName << "mydb"); - ASSERT_THROWS(DatabaseType::parse(IDLParserErrorContext("DatabaseType"), dbObj), - AssertionException); + ASSERT_THROWS(DatabaseType::parse(IDLParserContext("DatabaseType"), dbObj), AssertionException); } } // unnamed namespace diff --git a/src/mongo/s/chunk_version.cpp b/src/mongo/s/chunk_version.cpp index ca260776a34..88d7833f10e 100644 --- a/src/mongo/s/chunk_version.cpp +++ b/src/mongo/s/chunk_version.cpp @@ -58,7 +58,7 @@ std::string CollectionGeneration::toString() const { ChunkVersion ChunkVersion::parse(const BSONElement& element) { auto parsedVersion = - ChunkVersion60Format::parse(IDLParserErrorContext("ChunkVersion"), element.Obj()); + ChunkVersion60Format::parse(IDLParserContext("ChunkVersion"), element.Obj()); auto version = parsedVersion.getVersion(); return ChunkVersion({parsedVersion.getEpoch(), parsedVersion.getTimestamp()}, {version.getSecs(), version.getInc()}); diff --git a/src/mongo/s/cluster_ddl.cpp b/src/mongo/s/cluster_ddl.cpp index 5010575774f..99d186fef90 100644 --- a/src/mongo/s/cluster_ddl.cpp +++ b/src/mongo/s/cluster_ddl.cpp @@ -109,7 +109,7 @@ CachedDatabaseInfo createDatabase(OperationContext* opCtx, << "Database " << dbName << " could not be created"); auto createDbResponse = ConfigsvrCreateDatabaseResponse::parse( - IDLParserErrorContext("configsvrCreateDatabaseResponse"), response.response); + IDLParserContext("configsvrCreateDatabaseResponse"), response.response); catalogCache->onStaleDatabaseVersion(dbName, createDbResponse.getDatabaseVersion()); dbStatus = catalogCache->getDatabase(opCtx, dbName); @@ -133,8 +133,8 @@ void createCollection(OperationContext* opCtx, const ShardsvrCreateCollection& r const auto remoteResponse = uassertStatusOK(cmdResponse.swResponse); uassertStatusOK(getStatusFromCommandResult(remoteResponse.data)); - auto createCollResp = CreateCollectionResponse::parse(IDLParserErrorContext("createCollection"), - remoteResponse.data); + auto createCollResp = + CreateCollectionResponse::parse(IDLParserContext("createCollection"), remoteResponse.data); auto catalogCache = Grid::get(opCtx)->catalogCache(); catalogCache->invalidateShardOrEntireCollectionEntryForShardedCollection( diff --git a/src/mongo/s/commands/cluster_abort_transaction_cmd.h b/src/mongo/s/commands/cluster_abort_transaction_cmd.h index 04c70945e35..734e3363f90 100644 --- a/src/mongo/s/commands/cluster_abort_transaction_cmd.h +++ b/src/mongo/s/commands/cluster_abort_transaction_cmd.h @@ -56,7 +56,7 @@ public: typename BasicCommandWithRequestParser<ClusterAbortTransactionCmdBase<Impl>>::RequestParser; void validateResult(const BSONObj& resultObj) final { - auto ctx = IDLParserErrorContext("AbortReply"); + auto ctx = IDLParserContext("AbortReply"); if (!BaseType::checkIsErrorStatus(resultObj, ctx)) { // Will throw if the result doesn't match the abortReply. Reply::parse(ctx, resultObj); diff --git a/src/mongo/s/commands/cluster_analyze.cpp b/src/mongo/s/commands/cluster_analyze.cpp index 4eca4a1238f..2575982722d 100644 --- a/src/mongo/s/commands/cluster_analyze.cpp +++ b/src/mongo/s/commands/cluster_analyze.cpp @@ -129,7 +129,7 @@ public: } void validateResult(const BSONObj& result) final { - auto ctx = IDLParserErrorContext("AnalyzeCommandReply"); + auto ctx = IDLParserContext("AnalyzeCommandReply"); if (checkIsErrorStatus(result, ctx)) { return; } diff --git a/src/mongo/s/commands/cluster_balancer_collection_status_cmd.cpp b/src/mongo/s/commands/cluster_balancer_collection_status_cmd.cpp index 50e654f5008..f0903d3894c 100644 --- a/src/mongo/s/commands/cluster_balancer_collection_status_cmd.cpp +++ b/src/mongo/s/commands/cluster_balancer_collection_status_cmd.cpp @@ -77,7 +77,7 @@ public: uassertStatusOK(cmdResponse.commandStatus); - return Response::parse(IDLParserErrorContext("BalancerCollectionStatusResponse"), + return Response::parse(IDLParserContext("BalancerCollectionStatusResponse"), cmdResponse.response); } diff --git a/src/mongo/s/commands/cluster_collection_mod_cmd.cpp b/src/mongo/s/commands/cluster_collection_mod_cmd.cpp index 38e62973687..a1b8cb4a250 100644 --- a/src/mongo/s/commands/cluster_collection_mod_cmd.cpp +++ b/src/mongo/s/commands/cluster_collection_mod_cmd.cpp @@ -127,7 +127,7 @@ public: } void validateResult(const BSONObj& resultObj) final { - auto ctx = IDLParserErrorContext("CollModReply"); + auto ctx = IDLParserContext("CollModReply"); if (checkIsErrorStatus(resultObj, ctx)) { return; } @@ -148,7 +148,7 @@ public: return; } - auto rawCtx = IDLParserErrorContext(kRawFieldName, &ctx); + auto rawCtx = IDLParserContext(kRawFieldName, &ctx); for (const auto& element : rawData.Obj()) { if (!rawCtx.checkAndAssertType(element, Object)) { return; diff --git a/src/mongo/s/commands/cluster_commit_transaction_cmd.h b/src/mongo/s/commands/cluster_commit_transaction_cmd.h index 72d21d6111e..926c2bbe6eb 100644 --- a/src/mongo/s/commands/cluster_commit_transaction_cmd.h +++ b/src/mongo/s/commands/cluster_commit_transaction_cmd.h @@ -55,7 +55,7 @@ public: ClusterCommitTransactionCmdBase<Impl>>::RequestParser; void validateResult(const BSONObj& resultObj) final { - auto ctx = IDLParserErrorContext("CommitReply"); + auto ctx = IDLParserContext("CommitReply"); if (!BaseType::checkIsErrorStatus(resultObj, ctx)) { // Will throw if the result doesn't match the commitReply. Reply::parse(ctx, resultObj); diff --git a/src/mongo/s/commands/cluster_count_cmd.cpp b/src/mongo/s/commands/cluster_count_cmd.cpp index 539717d9de7..bfb24f62ce4 100644 --- a/src/mongo/s/commands/cluster_count_cmd.cpp +++ b/src/mongo/s/commands/cluster_count_cmd.cpp @@ -100,7 +100,7 @@ public: std::vector<AsyncRequestsSender::Response> shardResponses; try { - auto countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj); + auto countRequest = CountCommandRequest::parse(IDLParserContext("count"), cmdObj); if (shouldDoFLERewrite(countRequest)) { processFLECountS(opCtx, nss, &countRequest); } @@ -134,7 +134,7 @@ public: collation); } catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& ex) { // Rewrite the count command as an aggregation. - auto countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj); + auto countRequest = CountCommandRequest::parse(IDLParserContext("count"), cmdObj); auto aggCmdOnView = uassertStatusOK(countCommandAsAggregationCommand(countRequest, nss)); auto aggCmdOnViewObj = OpMsgRequest::fromDBAndBody(nss.db(), aggCmdOnView).body; @@ -200,7 +200,7 @@ public: CountCommandRequest countRequest(NamespaceStringOrUUID(NamespaceString{})); try { - countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), request); + countRequest = CountCommandRequest::parse(IDLParserContext("count"), request); } catch (...) { return exceptionToStatus(); } @@ -240,7 +240,7 @@ public: } catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& ex) { CountCommandRequest countRequest(NamespaceStringOrUUID(NamespaceString{})); try { - countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj); + countRequest = CountCommandRequest::parse(IDLParserContext("count"), cmdObj); } catch (...) { return exceptionToStatus(); } diff --git a/src/mongo/s/commands/cluster_create_indexes_cmd.cpp b/src/mongo/s/commands/cluster_create_indexes_cmd.cpp index 9b2246e571b..ef3aacd159c 100644 --- a/src/mongo/s/commands/cluster_create_indexes_cmd.cpp +++ b/src/mongo/s/commands/cluster_create_indexes_cmd.cpp @@ -140,7 +140,7 @@ public: * 'code' & 'codeName' are permitted in either scenario, but non-zero 'code' indicates "not ok". */ void validateResult(const BSONObj& result) final { - auto ctx = IDLParserErrorContext("createIndexesReply"); + auto ctx = IDLParserContext("createIndexesReply"); if (checkIsErrorStatus(result, ctx)) { return; } @@ -159,7 +159,7 @@ public: return; } - auto rawCtx = IDLParserErrorContext(kRawFieldName, &ctx); + auto rawCtx = IDLParserContext(kRawFieldName, &ctx); for (const auto& element : rawData.Obj()) { if (!rawCtx.checkAndAssertType(element, Object)) { return; diff --git a/src/mongo/s/commands/cluster_drop_indexes_cmd.cpp b/src/mongo/s/commands/cluster_drop_indexes_cmd.cpp index a4fbf12625e..45b20abae15 100644 --- a/src/mongo/s/commands/cluster_drop_indexes_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_indexes_cmd.cpp @@ -71,7 +71,7 @@ public: } void validateResult(const BSONObj& resultObj) final { - auto ctx = IDLParserErrorContext("DropIndexesReply"); + auto ctx = IDLParserContext("DropIndexesReply"); if (!checkIsErrorStatus(resultObj, ctx)) { Reply::parse(ctx, resultObj.removeField(kRawFieldName)); if (resultObj.hasField(kRawFieldName)) { diff --git a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp index c4fadfc733d..ac5f87a6d85 100644 --- a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp +++ b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp @@ -90,7 +90,7 @@ public: uassertStatusOK(response.writeConcernStatus); auto createDbResponse = ConfigsvrCreateDatabaseResponse::parse( - IDLParserErrorContext("configsvrCreateDatabaseResponse"), response.response); + IDLParserContext("configsvrCreateDatabaseResponse"), response.response); catalogCache->onStaleDatabaseVersion(dbName, createDbResponse.getDatabaseVersion()); purgeDatabaseOnExit.dismiss(); } diff --git a/src/mongo/s/commands/cluster_explain_cmd.cpp b/src/mongo/s/commands/cluster_explain_cmd.cpp index 00ed9bfd521..8b8f03db407 100644 --- a/src/mongo/s/commands/cluster_explain_cmd.cpp +++ b/src/mongo/s/commands/cluster_explain_cmd.cpp @@ -167,8 +167,8 @@ std::unique_ptr<CommandInvocation> ClusterExplainCmd::parse(OperationContext* op // To enforce API versioning auto cmdObj = ExplainCommandRequest::parse( - IDLParserErrorContext(ExplainCommandRequest::kCommandName, - APIParameters::get(opCtx).getAPIStrict().value_or(false)), + IDLParserContext(ExplainCommandRequest::kCommandName, + APIParameters::get(opCtx).getAPIStrict().value_or(false)), request.body); std::string dbName = cmdObj.getDbName().toString(); ExplainOptions::Verbosity verbosity = cmdObj.getVerbosity(); diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp index afa76fd80cd..9d509016a82 100644 --- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp @@ -119,7 +119,7 @@ boost::optional<BSONObj> getLet(const BSONObj& cmdObj) { boost::optional<LegacyRuntimeConstants> getLegacyRuntimeConstants(const BSONObj& cmdObj) { if (auto rcElem = cmdObj.getField("runtimeConstants"_sd); rcElem.type() == BSONType::Object) { - IDLParserErrorContext ctx("internalLegacyRuntimeConstants"); + IDLParserContext ctx("internalLegacyRuntimeConstants"); return LegacyRuntimeConstants::parse(ctx, rcElem.embeddedObject()); } return boost::none; @@ -375,7 +375,7 @@ public: const BSONObj& cmdObj = [&]() { // Check whether the query portion needs to be rewritten for FLE. auto findAndModifyRequest = write_ops::FindAndModifyCommandRequest::parse( - IDLParserErrorContext("ClusterFindAndModify"), request.body); + IDLParserContext("ClusterFindAndModify"), request.body); if (shouldDoFLERewrite(findAndModifyRequest)) { auto newRequest = processFLEFindAndModifyExplainMongos(opCtx, findAndModifyRequest); return newRequest.first.toBSON(request.body); @@ -565,7 +565,7 @@ private: if (feature_flags::gFeatureFlagUpdateDocumentShardKeyUsingTransactionApi.isEnabled( serverGlobalParams.featureCompatibility)) { auto parsedRequest = write_ops::FindAndModifyCommandRequest::parse( - IDLParserErrorContext("ClusterFindAndModify"), cmdObj); + IDLParserContext("ClusterFindAndModify"), cmdObj); // Strip write concern because this command will be sent as part of a // transaction and the write concern has already been loaded onto the opCtx and // will be picked up by the transaction API. diff --git a/src/mongo/s/commands/cluster_list_collections_cmd.cpp b/src/mongo/s/commands/cluster_list_collections_cmd.cpp index 64093b61191..0f1a1eab2f2 100644 --- a/src/mongo/s/commands/cluster_list_collections_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_collections_cmd.cpp @@ -179,8 +179,7 @@ BSONObj rewriteCommandForListingOwnCollections(OperationContext* opCtx, // testing because an error while parsing indicates an internal error, not something that should // surface to a user. if (getTestCommandsEnabled()) { - ListCollections::parse(IDLParserErrorContext("ListCollectionsForOwnCollections"), - rewrittenCmd); + ListCollections::parse(IDLParserContext("ListCollectionsForOwnCollections"), rewrittenCmd); } return rewrittenCmd; @@ -258,7 +257,7 @@ public: void validateResult(const BSONObj& result) final { StringDataSet ignorableFields({ErrorReply::kOkFieldName}); - ListCollectionsReply::parse(IDLParserErrorContext("ListCollectionsReply"), + ListCollectionsReply::parse(IDLParserContext("ListCollectionsReply"), result.removeFields(ignorableFields)); } diff --git a/src/mongo/s/commands/cluster_map_reduce_agg.cpp b/src/mongo/s/commands/cluster_map_reduce_agg.cpp index 2ea18a9500e..d25acff8bc7 100644 --- a/src/mongo/s/commands/cluster_map_reduce_agg.cpp +++ b/src/mongo/s/commands/cluster_map_reduce_agg.cpp @@ -148,7 +148,7 @@ bool runAggregationMapReduce(OperationContext* opCtx, const BSONObj& cmd, BSONObjBuilder& result, boost::optional<ExplainOptions::Verbosity> verbosity) { - auto parsedMr = MapReduceCommandRequest::parse(IDLParserErrorContext("mapReduce"), cmd); + auto parsedMr = MapReduceCommandRequest::parse(IDLParserContext("mapReduce"), cmd); stdx::unordered_set<NamespaceString> involvedNamespaces{parsedMr.getNamespace()}; auto hasOutDB = parsedMr.getOutOptions().getDatabaseName(); auto resolvedOutNss = NamespaceString{hasOutDB ? *hasOutDB : parsedMr.getNamespace().db(), diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp index c24272ef7ac..3c1c48cb609 100644 --- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp @@ -93,7 +93,7 @@ public: const std::string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) { - auto request = MovePrimary::parse(IDLParserErrorContext("MovePrimary"), cmdObj); + auto request = MovePrimary::parse(IDLParserContext("MovePrimary"), cmdObj); const string db = parseNs("", cmdObj); const StringData toShard(request.getTo()); diff --git a/src/mongo/s/commands/cluster_multicast_cmd.cpp b/src/mongo/s/commands/cluster_multicast_cmd.cpp index 834a786769f..4a38364c63b 100644 --- a/src/mongo/s/commands/cluster_multicast_cmd.cpp +++ b/src/mongo/s/commands/cluster_multicast_cmd.cpp @@ -91,7 +91,7 @@ public: const std::string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) override { - IDLParserErrorContext ctx("ClusterMulticast"); + IDLParserContext ctx("ClusterMulticast"); auto args = ClusterMulticast::parse(ctx, cmdObj); // Grab an arbitrary executor. diff --git a/src/mongo/s/commands/cluster_rename_collection_cmd.cpp b/src/mongo/s/commands/cluster_rename_collection_cmd.cpp index 1df93f9458e..b109fdcc556 100644 --- a/src/mongo/s/commands/cluster_rename_collection_cmd.cpp +++ b/src/mongo/s/commands/cluster_rename_collection_cmd.cpp @@ -125,7 +125,7 @@ public: uassertStatusOK(cmdResponse.commandStatus); auto renameCollResp = RenameCollectionResponse::parse( - IDLParserErrorContext("renameCollection"), cmdResponse.response); + IDLParserContext("renameCollection"), cmdResponse.response); catalogCache->invalidateShardOrEntireCollectionEntryForShardedCollection( toNss, renameCollResp.getCollectionVersion(), dbInfo->getPrimary()); diff --git a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp index 8db311e9c0b..58d6c63891a 100644 --- a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp +++ b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp @@ -71,8 +71,8 @@ public: uassertStatusOK(cmdResponse.writeConcernStatus); // Quickly pick up the new defaults by setting them in the cache. - auto newDefaults = RWConcernDefault::parse( - IDLParserErrorContext("ClusterSetDefaultRWConcern"), cmdResponse.response); + auto newDefaults = RWConcernDefault::parse(IDLParserContext("ClusterSetDefaultRWConcern"), + cmdResponse.response); if (auto optWC = newDefaults.getDefaultWriteConcern()) { if (optWC->hasCustomWriteMode()) { LOGV2_WARNING( @@ -155,7 +155,7 @@ public: uassertStatusOK(cmdResponse.commandStatus); return GetDefaultRWConcernResponse::parse( - IDLParserErrorContext("ClusterGetDefaultRWConcernResponse"), cmdResponse.response); + IDLParserContext("ClusterGetDefaultRWConcernResponse"), cmdResponse.response); } private: diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp index 4741bebba5e..f5245136e2c 100644 --- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp +++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp @@ -96,8 +96,7 @@ public: "Sharding a Queryable Encryption state collection is not allowed", !nss.isFLE2StateCollection()); - auto shardCollRequest = - ShardCollection::parse(IDLParserErrorContext("ShardCollection"), cmdObj); + auto shardCollRequest = ShardCollection::parse(IDLParserContext("ShardCollection"), cmdObj); ShardsvrCreateCollection shardsvrCollRequest(nss); CreateCollectionRequest requestParamsObj; diff --git a/src/mongo/s/commands/cluster_user_management_commands.cpp b/src/mongo/s/commands/cluster_user_management_commands.cpp index 210d1e20b00..f6384772b80 100644 --- a/src/mongo/s/commands/cluster_user_management_commands.cpp +++ b/src/mongo/s/commands/cluster_user_management_commands.cpp @@ -77,7 +77,7 @@ void uassertEmptyReply(BSONObj obj) { template <typename Request, typename Reply> Reply parseUMCReply(BSONObj obj) try { - return Reply::parse(IDLParserErrorContext(Request::kCommandName), obj); + return Reply::parse(IDLParserContext(Request::kCommandName), obj); } catch (const AssertionException& ex) { uasserted(ex.code(), "Received invalid response from {} command: {}, error: {}"_format( diff --git a/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp b/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp index 9af5f532a74..ea2e17ee350 100644 --- a/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp +++ b/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp @@ -105,7 +105,7 @@ public: "The array element in 'apiVersionErrors' should be object", error.type() == Object); ErrorReplyElement apiVersionError = ErrorReplyElement::parse( - IDLParserErrorContext("ErrorReplyElement"), error.Obj()); + IDLParserContext("ErrorReplyElement"), error.Obj()); // Ensure that the final output doesn't exceed max BSON size. apiVersionError.setShard(StringData(shardRes.shardId.toString())); diff --git a/src/mongo/s/commands/internal_transactions_test_command.h b/src/mongo/s/commands/internal_transactions_test_command.h index bbbea80de38..a605722c7f5 100644 --- a/src/mongo/s/commands/internal_transactions_test_command.h +++ b/src/mongo/s/commands/internal_transactions_test_command.h @@ -91,7 +91,7 @@ public: // from the command to append $db, which FindCommandRequest expects. auto findOpMsgRequest = OpMsgRequest::fromDBAndBody(dbName, command); auto findCommand = FindCommandRequest::parse( - IDLParserErrorContext("FindCommandRequest", false /* apiStrict */), + IDLParserContext("FindCommandRequest", false /* apiStrict */), findOpMsgRequest.body); auto docs = txnClient.exhaustiveFind(findCommand).get(); diff --git a/src/mongo/s/database_version.h b/src/mongo/s/database_version.h index 5de01497318..3868c3b370b 100644 --- a/src/mongo/s/database_version.h +++ b/src/mongo/s/database_version.h @@ -54,7 +54,7 @@ public: DatabaseVersion() = default; explicit DatabaseVersion(const BSONObj& obj) { - DatabaseVersionBase::parseProtected(IDLParserErrorContext("DatabaseVersion"), obj); + DatabaseVersionBase::parseProtected(IDLParserContext("DatabaseVersion"), obj); } explicit DatabaseVersion(const DatabaseVersionBase& dbv) : DatabaseVersionBase(dbv) {} diff --git a/src/mongo/s/query/async_results_merger_test.cpp b/src/mongo/s/query/async_results_merger_test.cpp index e20c06538f9..ef7817b0961 100644 --- a/src/mongo/s/query/async_results_merger_test.cpp +++ b/src/mongo/s/query/async_results_merger_test.cpp @@ -50,7 +50,7 @@ namespace mongo { namespace { LogicalSessionId parseSessionIdFromCmd(BSONObj cmdObj) { - return LogicalSessionId::parse(IDLParserErrorContext("lsid"), cmdObj["lsid"].Obj()); + return LogicalSessionId::parse(IDLParserContext("lsid"), cmdObj["lsid"].Obj()); } BSONObj makePostBatchResumeToken(Timestamp clusterTime) { diff --git a/src/mongo/s/query/document_source_merge_cursors.cpp b/src/mongo/s/query/document_source_merge_cursors.cpp index c6f8f3fbaf6..b2881d81415 100644 --- a/src/mongo/s/query/document_source_merge_cursors.cpp +++ b/src/mongo/s/query/document_source_merge_cursors.cpp @@ -129,7 +129,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceMergeCursors::createFromBson( "$mergeCursors stage expected an object as argument", elem.type() == BSONType::Object); auto ownedObj = elem.embeddedObject().getOwned(); - auto armParams = AsyncResultsMergerParams::parse(IDLParserErrorContext(kStageName), ownedObj); + auto armParams = AsyncResultsMergerParams::parse(IDLParserContext(kStageName), ownedObj); return new DocumentSourceMergeCursors(expCtx, std::move(armParams), std::move(ownedObj)); } diff --git a/src/mongo/s/read_write_concern_defaults_cache_lookup_mongos.cpp b/src/mongo/s/read_write_concern_defaults_cache_lookup_mongos.cpp index 7a2c6b5b737..a506a7c30c0 100644 --- a/src/mongo/s/read_write_concern_defaults_cache_lookup_mongos.cpp +++ b/src/mongo/s/read_write_concern_defaults_cache_lookup_mongos.cpp @@ -51,8 +51,8 @@ boost::optional<RWConcernDefault> readWriteConcernDefaultsCacheLookupMongoS( uassertStatusOK(cmdResponse.commandStatus); - return RWConcernDefault::parse( - IDLParserErrorContext("readWriteConcernDefaultsCacheLookupMongoS"), cmdResponse.response); + return RWConcernDefault::parse(IDLParserContext("readWriteConcernDefaultsCacheLookupMongoS"), + cmdResponse.response); } } // namespace mongo diff --git a/src/mongo/s/request_types/merge_chunks_request_test.cpp b/src/mongo/s/request_types/merge_chunks_request_test.cpp index b631ca1dffa..ff7cac5d91c 100644 --- a/src/mongo/s/request_types/merge_chunks_request_test.cpp +++ b/src/mongo/s/request_types/merge_chunks_request_test.cpp @@ -40,7 +40,7 @@ namespace { using unittest::assertGet; ChunkRange chunkRange(BSON("a" << 1), BSON("a" << 10)); -IDLParserErrorContext ctx("_configsvrCommitChunksMerge"); +IDLParserContext ctx("_configsvrCommitChunksMerge"); TEST(ConfigSvrMergeChunks, BasicValidConfigCommand) { auto collUUID = UUID::gen(); diff --git a/src/mongo/s/shard_util.cpp b/src/mongo/s/shard_util.cpp index 2824eabacc2..77c0ec29481 100644 --- a/src/mongo/s/shard_util.cpp +++ b/src/mongo/s/shard_util.cpp @@ -156,7 +156,7 @@ StatusWith<std::vector<BSONObj>> selectChunkSplitPoints(OperationContext* opCtx, } const auto response = AutoSplitVectorResponse::parse( - IDLParserErrorContext("AutoSplitVectorResponse"), std::move(cmdStatus.getValue().response)); + IDLParserContext("AutoSplitVectorResponse"), std::move(cmdStatus.getValue().response)); return response.getSplitKeys(); } diff --git a/src/mongo/scripting/mozjs/mongo.cpp b/src/mongo/scripting/mozjs/mongo.cpp index 6518fb14c48..a2ad8272d9e 100644 --- a/src/mongo/scripting/mozjs/mongo.cpp +++ b/src/mongo/scripting/mozjs/mongo.cpp @@ -585,8 +585,8 @@ void MongoExternalInfo::construct(JSContext* cx, JS::CallArgs args) { uassert(4938001, "the 'api' option for Mongo() must be an object", options["api"].isABSONObj()); - apiParameters = ClientAPIVersionParameters::parse(IDLParserErrorContext("api"_sd), - options["api"].Obj()); + apiParameters = + ClientAPIVersionParameters::parse(IDLParserContext("api"_sd), options["api"].Obj()); if (apiParameters.getDeprecationErrors().value_or(false) || apiParameters.getStrict().value_or(false)) { uassert(4938002, diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp index e1a0616b9fd..2ca618d4e5f 100644 --- a/src/mongo/shell/bench.cpp +++ b/src/mongo/shell/bench.cpp @@ -630,7 +630,7 @@ BenchRunOp opFromBson(const BSONObj& op) { ReadPreference mode; try { - mode = ReadPreference_parse(IDLParserErrorContext("mode"), arg.str()); + mode = ReadPreference_parse(IDLParserContext("mode"), arg.str()); } catch (DBException& e) { e.addContext("benchRun(): Could not parse readPrefMode argument"); throw; @@ -900,8 +900,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) { str::stream() << "Unable to create session due to error " << result, conn->runCommand("admin", BSON("startSession" << 1), result)); - lsid.emplace( - LogicalSessionIdToClient::parse(IDLParserErrorContext("lsid"), result["id"].Obj())); + lsid.emplace(LogicalSessionIdToClient::parse(IDLParserContext("lsid"), result["id"].Obj())); } BenchRunOp::State opState(&_rng, &bsonTemplateEvaluator, &_statsBlackHole); diff --git a/src/mongo/shell/encrypted_dbclient_base.cpp b/src/mongo/shell/encrypted_dbclient_base.cpp index 115df4940cf..3c90565d355 100644 --- a/src/mongo/shell/encrypted_dbclient_base.cpp +++ b/src/mongo/shell/encrypted_dbclient_base.cpp @@ -527,7 +527,7 @@ boost::optional<EncryptedFieldConfig> EncryptedDBClientBase::getEncryptedFieldCo if (efc.eoo() || !efc.isABSONObj()) { return boost::none; } - return EncryptedFieldConfig::parse(IDLParserErrorContext("encryptedFields"), efc.Obj()); + return EncryptedFieldConfig::parse(IDLParserContext("encryptedFields"), efc.Obj()); } void EncryptedDBClientBase::compact(JSContext* cx, JS::CallArgs args) { @@ -674,7 +674,7 @@ SecureVector<uint8_t> EncryptedDBClientBase::getKeyMaterialFromDisk(const UUID& uasserted(ErrorCodes::BadValue, "Invalid keyID."); } - auto keyStoreRecord = KeyStoreRecord::parse(IDLParserErrorContext("root"), dataKeyObj); + auto keyStoreRecord = KeyStoreRecord::parse(IDLParserContext("root"), dataKeyObj); if (dataKeyObj.hasField("version"_sd)) { uassert(ErrorCodes::BadValue, "Invalid version, must be either 0 or undefined", @@ -813,7 +813,7 @@ std::unique_ptr<DBClientBase> createEncryptedDBClientBase(std::unique_ptr<DBClie arg.isObject()); const BSONObj obj = mozjs::ValueWriter(cx, arg).toBSON(); - encryptionOptions = encryptionOptions.parse(IDLParserErrorContext("root"), obj); + encryptionOptions = encryptionOptions.parse(IDLParserContext("root"), obj); // IDL does not perform a deep copy of BSONObjs when parsing, so we must get an // owned copy of the schemaMap. diff --git a/src/mongo/shell/kms.cpp b/src/mongo/shell/kms.cpp index 4bea437a267..792be3ab1f3 100644 --- a/src/mongo/shell/kms.cpp +++ b/src/mongo/shell/kms.cpp @@ -75,7 +75,7 @@ void KMSServiceController::registerFactory(KMSProviderEnum provider, std::unique_ptr<KMSService> KMSServiceController::createFromClient(StringData kmsProvider, const BSONObj& config) { KMSProviderEnum provider = - KMSProvider_parse(IDLParserErrorContext("client fle options"), kmsProvider); + KMSProvider_parse(IDLParserContext("client fle options"), kmsProvider); auto service = _factories.at(provider)->create(config); uassert(51192, str::stream() << "Cannot find client kms provider " << kmsProvider, service); @@ -85,7 +85,7 @@ std::unique_ptr<KMSService> KMSServiceController::createFromClient(StringData km std::unique_ptr<KMSService> KMSServiceController::createFromDisk(const BSONObj& config, const BSONObj& masterKey) { auto providerObj = masterKey.getStringField("provider"_sd); - auto provider = KMSProvider_parse(IDLParserErrorContext("root"), providerObj); + auto provider = KMSProvider_parse(IDLParserContext("root"), providerObj); auto service = _factories.at(provider)->create(config); uassert(51193, str::stream() << "Cannot find disk kms provider " << providerObj, service); return service; diff --git a/src/mongo/shell/kms_aws.cpp b/src/mongo/shell/kms_aws.cpp index 493fc482d1c..f0a7850cbfa 100644 --- a/src/mongo/shell/kms_aws.cpp +++ b/src/mongo/shell/kms_aws.cpp @@ -182,7 +182,7 @@ std::vector<uint8_t> AWSKMSService::encrypt(ConstDataRange cdr, StringData kmsKe if (!field.eoo()) { AwsKMSError awsResponse; try { - awsResponse = AwsKMSError::parse(IDLParserErrorContext("awsEncryptError"), obj); + awsResponse = AwsKMSError::parse(IDLParserContext("awsEncryptError"), obj); } catch (DBException& dbe) { uasserted(51274, str::stream() << "AWS KMS failed to parse error message: " << dbe.toString() @@ -194,7 +194,7 @@ std::vector<uint8_t> AWSKMSService::encrypt(ConstDataRange cdr, StringData kmsKe << awsResponse.getMessage()); } - auto awsResponse = AwsEncryptResponse::parse(IDLParserErrorContext("awsEncryptResponse"), obj); + auto awsResponse = AwsEncryptResponse::parse(IDLParserContext("awsEncryptResponse"), obj); auto blobStr = base64::decode(awsResponse.getCiphertextBlob().toString()); @@ -218,7 +218,7 @@ BSONObj AWSKMSService::encryptDataKeyByString(ConstDataRange cdr, StringData key } SecureVector<uint8_t> AWSKMSService::decrypt(ConstDataRange cdr, BSONObj masterKey) { - auto awsMasterKey = AwsMasterKey::parse(IDLParserErrorContext("awsMasterKey"), masterKey); + auto awsMasterKey = AwsMasterKey::parse(IDLParserContext("awsMasterKey"), masterKey); auto request = UniqueKmsRequest(kms_decrypt_request_new( reinterpret_cast<const uint8_t*>(cdr.data()), cdr.length(), nullptr)); @@ -243,7 +243,7 @@ SecureVector<uint8_t> AWSKMSService::decrypt(ConstDataRange cdr, BSONObj masterK if (!field.eoo()) { AwsKMSError awsResponse; try { - awsResponse = AwsKMSError::parse(IDLParserErrorContext("awsDecryptError"), obj); + awsResponse = AwsKMSError::parse(IDLParserContext("awsDecryptError"), obj); } catch (DBException& dbe) { uasserted(51275, str::stream() << "AWS KMS failed to parse error message: " << dbe.toString() @@ -255,7 +255,7 @@ SecureVector<uint8_t> AWSKMSService::decrypt(ConstDataRange cdr, BSONObj masterK << awsResponse.getMessage()); } - auto awsResponse = AwsDecryptResponse::parse(IDLParserErrorContext("awsDecryptResponse"), obj); + auto awsResponse = AwsDecryptResponse::parse(IDLParserContext("awsDecryptResponse"), obj); auto blobStr = base64::decode(awsResponse.getPlaintext().toString()); @@ -307,7 +307,7 @@ public: return nullptr; } auto obj = field.Obj(); - return AWSKMSService::create(AwsKMS::parse(IDLParserErrorContext("root"), obj)); + return AWSKMSService::create(AwsKMS::parse(IDLParserContext("root"), obj)); } }; diff --git a/src/mongo/shell/kms_azure.cpp b/src/mongo/shell/kms_azure.cpp index 410961deb86..1673f966396 100644 --- a/src/mongo/shell/kms_azure.cpp +++ b/src/mongo/shell/kms_azure.cpp @@ -194,7 +194,7 @@ std::unique_ptr<uint8_t, decltype(std::free)*> AzureKMSService::makeRequest( AzureKMSError azureResponse; try { azureResponse = - AzureKMSError::parse(IDLParserErrorContext("azureError"), obj["error"].Obj()); + AzureKMSError::parse(IDLParserContext("azureError"), obj["error"].Obj()); } catch (DBException& dbe) { uasserted(5265102, "Azure KMS failed to parse error message: {}, Response : {}"_format( @@ -206,7 +206,7 @@ std::unique_ptr<uint8_t, decltype(std::free)*> AzureKMSService::makeRequest( azureResponse.getMessage())); } - auto azureResponse = AzureResponseT::parse(IDLParserErrorContext("azureResponse"), obj); + auto azureResponse = AzureResponseT::parse(IDLParserContext("azureResponse"), obj); auto b64Url = azureResponse.getValue().toString(); std::unique_ptr<uint8_t, decltype(std::free)*> raw_str( @@ -218,7 +218,7 @@ std::unique_ptr<uint8_t, decltype(std::free)*> AzureKMSService::makeRequest( SecureVector<uint8_t> AzureKMSService::decrypt(ConstDataRange cdr, BSONObj masterKey) { - auto azureMasterKey = AzureMasterKey::parse(IDLParserErrorContext("azureMasterKey"), masterKey); + auto azureMasterKey = AzureMasterKey::parse(IDLParserContext("azureMasterKey"), masterKey); StringData bearerToken = _oauthService->getBearerToken(); HostAndPort keyVaultEndpoint = parseEndpoint(azureMasterKey.getKeyVaultEndpoint()); @@ -241,8 +241,7 @@ SecureVector<uint8_t> AzureKMSService::decrypt(ConstDataRange cdr, BSONObj maste BSONObj AzureKMSService::encryptDataKeyByBSONObj(ConstDataRange cdr, BSONObj keyId) { StringData bearerToken = _oauthService->getBearerToken(); - AzureMasterKey masterKey = - AzureMasterKey::parse(IDLParserErrorContext("azureMasterKey"), keyId); + AzureMasterKey masterKey = AzureMasterKey::parse(IDLParserContext("azureMasterKey"), keyId); HostAndPort keyVaultEndpoint = parseEndpoint(masterKey.getKeyVaultEndpoint()); @@ -287,7 +286,7 @@ public: field.type() == BSONType::Object); auto obj = field.Obj(); - return AzureKMSService::create(AzureKMS::parse(IDLParserErrorContext("root"), obj)); + return AzureKMSService::create(AzureKMS::parse(IDLParserContext("root"), obj)); } }; diff --git a/src/mongo/shell/kms_gcp.cpp b/src/mongo/shell/kms_gcp.cpp index beb06ae9c89..dfe439bd85e 100644 --- a/src/mongo/shell/kms_gcp.cpp +++ b/src/mongo/shell/kms_gcp.cpp @@ -166,7 +166,7 @@ private: std::vector<uint8_t> GCPKMSService::encrypt(ConstDataRange cdr, const BSONObj& kmsKeyId) { StringData bearerToken = _oauthService->getBearerToken(); - GcpMasterKey masterKey = GcpMasterKey::parse(IDLParserErrorContext("gcpMasterKey"), kmsKeyId); + GcpMasterKey masterKey = GcpMasterKey::parse(IDLParserContext("gcpMasterKey"), kmsKeyId); auto request = UniqueKmsRequest(kms_gcp_request_encrypt_new( _server.host().c_str(), @@ -195,7 +195,7 @@ std::vector<uint8_t> GCPKMSService::encrypt(ConstDataRange cdr, const BSONObj& k GcpKMSError gcpResponse; try { gcpResponse = - GcpKMSError::parse(IDLParserErrorContext("gcpEncryptError"), obj["error"].Obj()); + GcpKMSError::parse(IDLParserContext("gcpEncryptError"), obj["error"].Obj()); } catch (DBException& dbe) { uasserted(5265005, str::stream() << "GCP KMS failed to parse error message: " << dbe.toString() @@ -207,7 +207,7 @@ std::vector<uint8_t> GCPKMSService::encrypt(ConstDataRange cdr, const BSONObj& k << gcpResponse.getStatus() << " : " << gcpResponse.getMessage()); } - auto gcpResponce = GcpEncryptResponse::parse(IDLParserErrorContext("gcpEncryptResponse"), obj); + auto gcpResponce = GcpEncryptResponse::parse(IDLParserContext("gcpEncryptResponse"), obj); auto blobStr = base64::decode(gcpResponce.getCiphertext()); @@ -215,7 +215,7 @@ std::vector<uint8_t> GCPKMSService::encrypt(ConstDataRange cdr, const BSONObj& k } SecureVector<uint8_t> GCPKMSService::decrypt(ConstDataRange cdr, BSONObj masterKey) { - auto gcpMasterKey = GcpMasterKey::parse(IDLParserErrorContext("gcpMasterKey"), masterKey); + auto gcpMasterKey = GcpMasterKey::parse(IDLParserContext("gcpMasterKey"), masterKey); StringData bearerToken = _oauthService->getBearerToken(); auto request = @@ -242,7 +242,7 @@ SecureVector<uint8_t> GCPKMSService::decrypt(ConstDataRange cdr, BSONObj masterK GcpKMSError gcpResponse; try { gcpResponse = - GcpKMSError::parse(IDLParserErrorContext("gcpDecryptError"), obj["error"].Obj()); + GcpKMSError::parse(IDLParserContext("gcpDecryptError"), obj["error"].Obj()); } catch (DBException& dbe) { uasserted(5265007, str::stream() << "GCP KMS failed to parse error message: " << dbe.toString() @@ -254,7 +254,7 @@ SecureVector<uint8_t> GCPKMSService::decrypt(ConstDataRange cdr, BSONObj masterK << gcpResponse.getStatus() << " : " << gcpResponse.getMessage()); } - auto gcpResponce = GcpDecryptResponse::parse(IDLParserErrorContext("gcpDecryptResponse"), obj); + auto gcpResponce = GcpDecryptResponse::parse(IDLParserContext("gcpDecryptResponse"), obj); auto blobStr = base64::decode(gcpResponce.getPlaintext()); @@ -264,7 +264,7 @@ SecureVector<uint8_t> GCPKMSService::decrypt(ConstDataRange cdr, BSONObj masterK BSONObj GCPKMSService::encryptDataKeyByBSONObj(ConstDataRange cdr, BSONObj keyId) { auto dataKey = encrypt(cdr, keyId); - GcpMasterKey masterKey = GcpMasterKey::parse(IDLParserErrorContext("gcpMasterKey"), keyId); + GcpMasterKey masterKey = GcpMasterKey::parse(IDLParserContext("gcpMasterKey"), keyId); GcpMasterKeyAndMaterial keyAndMaterial; keyAndMaterial.setKeyMaterial(std::move(dataKey)); @@ -324,7 +324,7 @@ public: "Misconfigured GCP KMS Config: {}"_format(field.toString()), field.type() == BSONType::Object); auto obj = field.Obj(); - return GCPKMSService::create(GcpKMS::parse(IDLParserErrorContext("root"), obj)); + return GCPKMSService::create(GcpKMS::parse(IDLParserContext("root"), obj)); } }; diff --git a/src/mongo/shell/kms_local.cpp b/src/mongo/shell/kms_local.cpp index 9e9d1952311..f67230ed45f 100644 --- a/src/mongo/shell/kms_local.cpp +++ b/src/mongo/shell/kms_local.cpp @@ -130,7 +130,7 @@ public: } auto obj = field.Obj(); - return LocalKMSService::create(LocalKMS::parse(IDLParserErrorContext("root"), obj)); + return LocalKMSService::create(LocalKMS::parse(IDLParserContext("root"), obj)); } }; diff --git a/src/mongo/shell/kms_network.cpp b/src/mongo/shell/kms_network.cpp index 6ff51892313..686b66ceaeb 100644 --- a/src/mongo/shell/kms_network.cpp +++ b/src/mongo/shell/kms_network.cpp @@ -177,8 +177,7 @@ void KMSOAuthService::makeBearerTokenRequest() { if (!field.eoo()) { OAuthErrorResponse oAuthErrorResponse; try { - oAuthErrorResponse = - OAuthErrorResponse::parse(IDLParserErrorContext("oauthError"), obj); + oAuthErrorResponse = OAuthErrorResponse::parse(IDLParserContext("oauthError"), obj); } catch (DBException& dbe) { uasserted(ErrorCodes::FailedToParse, str::stream() << "Failed to parse error message: " << dbe.toString() @@ -195,7 +194,7 @@ void KMSOAuthService::makeBearerTokenRequest() { << description); } - auto kmsResponse = OAuthResponse::parse(IDLParserErrorContext("OAuthResponse"), obj); + auto kmsResponse = OAuthResponse::parse(IDLParserContext("OAuthResponse"), obj); _cachedToken = kmsResponse.getAccess_token().toString(); diff --git a/src/mongo/shell/kms_test.cpp b/src/mongo/shell/kms_test.cpp index d0323a25f48..f8e7d2f9f2b 100644 --- a/src/mongo/shell/kms_test.cpp +++ b/src/mongo/shell/kms_test.cpp @@ -76,7 +76,7 @@ TEST(KmsTest, TestGoodKey) { service->encryptDataKeyByString(ConstDataRange(myKey.rawData(), myKey.size()), ""); LocalMasterKeyAndMaterial glob = - LocalMasterKeyAndMaterial::parse(IDLParserErrorContext("root"), material); + LocalMasterKeyAndMaterial::parse(IDLParserContext("root"), material); auto keyMaterial = glob.getKeyMaterial(); diff --git a/src/mongo/transport/transport_layer_asio_integration_test.cpp b/src/mongo/transport/transport_layer_asio_integration_test.cpp index 1fd1c67de14..5338c1c7dca 100644 --- a/src/mongo/transport/transport_layer_asio_integration_test.cpp +++ b/src/mongo/transport/transport_layer_asio_integration_test.cpp @@ -197,7 +197,7 @@ TEST(TransportLayerASIO, exhaustIsMasterShouldReceiveMultipleReplies) { ASSERT_OK(reply.status); ASSERT(reply.moreToCome); prevTime = reply.data.getField("localTime").Date(); - topologyVersion = TopologyVersion::parse(IDLParserErrorContext("TopologyVersion"), + topologyVersion = TopologyVersion::parse(IDLParserContext("TopologyVersion"), reply.data.getField("topologyVersion").Obj()); } @@ -211,7 +211,7 @@ TEST(TransportLayerASIO, exhaustIsMasterShouldReceiveMultipleReplies) { ASSERT_GT(replyTime, prevTime); auto replyTopologyVersion = TopologyVersion::parse( - IDLParserErrorContext("TopologyVersion"), reply.data.getField("topologyVersion").Obj()); + IDLParserContext("TopologyVersion"), reply.data.getField("topologyVersion").Obj()); ASSERT_EQ(replyTopologyVersion.getProcessId(), topologyVersion.getProcessId()); ASSERT_EQ(replyTopologyVersion.getCounter(), topologyVersion.getCounter()); } diff --git a/src/mongo/util/net/ssl_parameters.cpp b/src/mongo/util/net/ssl_parameters.cpp index b1aeda31ef0..2d6784a5539 100644 --- a/src/mongo/util/net/ssl_parameters.cpp +++ b/src/mongo/util/net/ssl_parameters.cpp @@ -185,7 +185,7 @@ Status TLSCATrustsSetParameter::set(const BSONElement& element) try { return {ErrorCodes::BadValue, "Value must be an array of trust definitions"}; } - IDLParserErrorContext ctx("tlsCATrusts"); + IDLParserContext ctx("tlsCATrusts"); auto trust = TLSCATrust::parse(ctx, trustElement.Obj()); if (trusts.find(trust.getSha256()) != trusts.end()) { |
