diff options
58 files changed, 133 insertions, 104 deletions
diff --git a/src/mongo/crypto/jwk_manager.cpp b/src/mongo/crypto/jwk_manager.cpp index 1189d18d4e3..f93648f640c 100644 --- a/src/mongo/crypto/jwk_manager.cpp +++ b/src/mongo/crypto/jwk_manager.cpp @@ -52,7 +52,7 @@ StringData reduceInt(StringData value) { } // namespace JWKManager::JWKManager(BSONObj data) { - auto keys = JWKSet::parse({"JWKSet"}, data); + auto keys = JWKSet::parse(IDLParserContext{"JWKSet"}, data); for (const auto& key : keys.getKeys()) { uassert(ErrorCodes::BadValue, str::stream() << "Only RSA key types are accepted at this time", diff --git a/src/mongo/db/api_parameters.cpp b/src/mongo/db/api_parameters.cpp index 5acc12b09b6..58230698989 100644 --- a/src/mongo/db/api_parameters.cpp +++ b/src/mongo/db/api_parameters.cpp @@ -63,7 +63,7 @@ APIParameters APIParameters::fromClient(const APIParametersFromClient& apiParams APIParameters APIParameters::fromBSON(const BSONObj& cmdObj) { return APIParameters::fromClient( - APIParametersFromClient::parse("APIParametersFromClient"_sd, cmdObj)); + APIParametersFromClient::parse(IDLParserContext{"APIParametersFromClient"}, cmdObj)); } void APIParameters::appendInfo(BSONObjBuilder* builder) const { diff --git a/src/mongo/db/auth/authorization_session_impl.cpp b/src/mongo/db/auth/authorization_session_impl.cpp index 4f33b63ef66..8d87618f80d 100644 --- a/src/mongo/db/auth/authorization_session_impl.cpp +++ b/src/mongo/db/auth/authorization_session_impl.cpp @@ -100,7 +100,7 @@ MONGO_INITIALIZER(ServerlessPrivilegePermittedMap)(InitializerContext*) try { auto matchType = static_cast<MatchTypeEnum>(i); auto matchTypeName = MatchType_serializer(matchType); auto dataObj = MatchType_get_extra_data(matchType); - auto data = MatchTypeExtraData::parse({matchTypeName}, dataObj); + auto data = MatchTypeExtraData::parse(IDLParserContext{matchTypeName}, dataObj); auto actionTypes = data.getServerlessActionTypes(); std::vector<std::string> actionsToParse; diff --git a/src/mongo/db/auth/validated_tenancy_scope.cpp b/src/mongo/db/auth/validated_tenancy_scope.cpp index 1be642a5422..ededcb6d3a3 100644 --- a/src/mongo/db/auth/validated_tenancy_scope.cpp +++ b/src/mongo/db/auth/validated_tenancy_scope.cpp @@ -72,7 +72,7 @@ ValidatedTenancyScope::ValidatedTenancyScope(BSONObj obj, InitTag tag) : _origin "Multitenancy not enabled, refusing to accept securityToken", gMultitenancySupport || (tag == InitTag::kInitForShell)); - auto token = SecurityToken::parse({"Security Token"}, obj); + auto token = SecurityToken::parse(IDLParserContext{"Security Token"}, obj); auto authenticatedUser = token.getAuthenticatedUser(); uassert(ErrorCodes::BadValue, "Security token authenticated user requires a valid Tenant ID", diff --git a/src/mongo/db/catalog/clustered_collection_util.cpp b/src/mongo/db/catalog/clustered_collection_util.cpp index 08259baee76..04316f17ed2 100644 --- a/src/mongo/db/catalog/clustered_collection_util.cpp +++ b/src/mongo/db/catalog/clustered_collection_util.cpp @@ -89,7 +89,8 @@ boost::optional<ClusteredCollectionInfo> parseClusteredInfo(const BSONElement& e return makeCanonicalClusteredInfoForLegacyFormat(); } - auto indexSpec = ClusteredIndexSpec::parse({"ClusteredUtil::parseClusteredInfo"}, elem.Obj()); + auto indexSpec = ClusteredIndexSpec::parse( + IDLParserContext{"ClusteredUtil::parseClusteredInfo"}, elem.Obj()); ensureClusteredIndexName(indexSpec); return makeCanonicalClusteredInfo(std::move(indexSpec)); } @@ -102,7 +103,7 @@ boost::optional<ClusteredCollectionInfo> createClusteredInfoForNewCollection( auto filteredIndexSpec = indexSpec.removeField("clustered"_sd); auto clusteredIndexSpec = ClusteredIndexSpec::parse( - {"ClusteredUtil::createClusteredInfoForNewCollection"}, filteredIndexSpec); + IDLParserContext{"ClusteredUtil::createClusteredInfoForNewCollection"}, filteredIndexSpec); ensureClusteredIndexName(clusteredIndexSpec); return makeCanonicalClusteredInfo(std::move(clusteredIndexSpec)); }; diff --git a/src/mongo/db/catalog/collection_options.cpp b/src/mongo/db/catalog/collection_options.cpp index eb7a9d4cf3c..e435ac8c7f9 100644 --- a/src/mongo/db/catalog/collection_options.cpp +++ b/src/mongo/db/catalog/collection_options.cpp @@ -183,7 +183,7 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P try { collectionOptions.changeStreamPreAndPostImagesOptions = ChangeStreamPreAndPostImagesOptions::parse( - {"changeStreamPreAndPostImagesOptions"}, e.Obj()); + IDLParserContext{"changeStreamPreAndPostImagesOptions"}, e.Obj()); } catch (const DBException& ex) { return ex.toStatus(); } @@ -204,8 +204,8 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P } try { - collectionOptions.indexOptionDefaults = - IndexOptionDefaults::parse({"CollectionOptions::parse"}, e.Obj()); + collectionOptions.indexOptionDefaults = IndexOptionDefaults::parse( + IDLParserContext{"CollectionOptions::parse"}, e.Obj()); } catch (const DBException& ex) { return ex.toStatus(); } @@ -222,7 +222,7 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P try { collectionOptions.validationAction = - ValidationAction_parse({"validationAction"}, e.String()); + ValidationAction_parse(IDLParserContext{"validationAction"}, e.String()); } catch (const DBException& exc) { return exc.toStatus(); } @@ -233,7 +233,7 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P try { collectionOptions.validationLevel = - ValidationLevel_parse({"validationLevel"}, e.String()); + ValidationLevel_parse(IDLParserContext{"validationLevel"}, e.String()); } catch (const DBException& exc) { return exc.toStatus(); } @@ -292,7 +292,7 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P try { collectionOptions.timeseries = - TimeseriesOptions::parse({"CollectionOptions::parse"}, e.Obj()); + TimeseriesOptions::parse(IDLParserContext{"CollectionOptions::parse"}, e.Obj()); } catch (const DBException& ex) { return ex.toStatus(); } @@ -304,7 +304,8 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P try { collectionOptions.encryptedFieldConfig = collection_options_validation::processAndValidateEncryptedFields( - EncryptedFieldConfig::parse({"CollectionOptions::parse"}, e.Obj())); + EncryptedFieldConfig::parse(IDLParserContext{"CollectionOptions::parse"}, + e.Obj())); } catch (const DBException& ex) { return ex.toStatus(); } diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp index 3589c047bcc..ecbbf35893c 100644 --- a/src/mongo/db/catalog/drop_indexes.cpp +++ b/src/mongo/db/catalog/drop_indexes.cpp @@ -580,7 +580,7 @@ Status dropIndexesForApplyOps(OperationContext* opCtx, BSONObjBuilder bob(cmdObj); bob.append("$db", nss.db()); auto cmdObjWithDb = bob.obj(); - auto parsed = DropIndexes::parse({"dropIndexes"}, cmdObjWithDb); + auto parsed = DropIndexes::parse(IDLParserContext{"dropIndexes"}, cmdObjWithDb); return writeConflictRetry(opCtx, "dropIndexes", nss.db(), [opCtx, &nss, &cmdObj, &parsed] { AutoGetCollection collection(opCtx, nss, MODE_X); diff --git a/src/mongo/db/commands/generic_servers.cpp b/src/mongo/db/commands/generic_servers.cpp index 14dd3cc15ee..b01d445a122 100644 --- a/src/mongo/db/commands/generic_servers.cpp +++ b/src/mongo/db/commands/generic_servers.cpp @@ -282,7 +282,7 @@ public: hangInGetLog.pauseWhileSet(); } - auto request = GetLogCommand::parse({"getLog"}, cmdObj); + auto request = GetLogCommand::parse(IDLParserContext{"getLog"}, cmdObj); auto logName = request.getCommandParameter(); if (logName == "*") { std::vector<std::string> names; diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index c7750690cb5..c189610d9db 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -318,7 +318,7 @@ public: public: Invocation(Command* cmd, const OpMsgRequest& request) : CommandInvocation(cmd), - _cmd(GetMoreCommandRequest::parse({"getMore"}, request.body)) { + _cmd(GetMoreCommandRequest::parse(IDLParserContext{"getMore"}, request.body)) { NamespaceString nss(_cmd.getDbName(), _cmd.getCollection()); uassert(ErrorCodes::InvalidNamespace, str::stream() << "Invalid namespace for getMore: " << nss.ns(), @@ -810,7 +810,8 @@ public: void validateResult(rpc::ReplyBuilderInterface* reply) { auto ret = reply->getBodyBuilder().asTempObj(); - CursorGetMoreReply::parse({"CursorGetMoreReply"}, ret.removeField("ok")); + CursorGetMoreReply::parse(IDLParserContext{"CursorGetMoreReply"}, + ret.removeField("ok")); } const GetMoreCommandRequest _cmd; diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp index ccfecb48501..e9478a9501c 100644 --- a/src/mongo/db/commands/parameters.cpp +++ b/src/mongo/db/commands/parameters.cpp @@ -193,7 +193,7 @@ Status setLogComponentVerbosity(const BSONObj& bsonSettings) { GetParameterOptions parseGetParameterOptions(BSONElement elem) { if (elem.type() == BSONType::Object) { - return GetParameterOptions::parse({"getParameter"}, elem.Obj()); + return GetParameterOptions::parse(IDLParserContext{"getParameter"}, elem.Obj()); } if ((elem.type() == BSONType::String) && (elem.valueStringDataSafe() == "*"_sd)) { GetParameterOptions ret; diff --git a/src/mongo/db/initialize_api_parameters.cpp b/src/mongo/db/initialize_api_parameters.cpp index 7e33daf526c..c0200c25d8b 100644 --- a/src/mongo/db/initialize_api_parameters.cpp +++ b/src/mongo/db/initialize_api_parameters.cpp @@ -43,7 +43,7 @@ namespace mongo { APIParametersFromClient initializeAPIParameters(const BSONObj& requestBody, Command* command) { auto apiParamsFromClient = - APIParametersFromClient::parse("APIParametersFromClient"_sd, requestBody); + APIParametersFromClient::parse(IDLParserContext{"APIParametersFromClient"}, requestBody); if (command->skipApiVersionCheck()) { return apiParamsFromClient; diff --git a/src/mongo/db/initialize_operation_session_info.cpp b/src/mongo/db/initialize_operation_session_info.cpp index 0ef4d2f2cdd..c00867e6386 100644 --- a/src/mongo/db/initialize_operation_session_info.cpp +++ b/src/mongo/db/initialize_operation_session_info.cpp @@ -44,7 +44,8 @@ OperationSessionInfoFromClient initializeOperationSessionInfo(OperationContext* bool requiresAuth, bool attachToOpCtx, bool isReplSetMemberOrMongos) { - auto osi = OperationSessionInfoFromClient::parse("OperationSessionInfo"_sd, requestBody); + auto osi = OperationSessionInfoFromClient::parse(IDLParserContext{"OperationSessionInfo"}, + requestBody); auto isAuthorizedForInternalClusterAction = AuthorizationSession::get(opCtx->getClient()) ->isAuthorizedForActionsOnResource(ResourcePattern::forClusterResource(), 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 b94b191f9ff..82224aad1af 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 @@ -294,7 +294,8 @@ boost::optional<Document> DocumentSourceFindAndModifyImageLookup::_forgeNoopImag for (size_t i = 0; i < operationDocs.size(); i++) { auto op = repl::DurableReplOperation::parse( - {"DocumentSourceFindAndModifyImageLookup::_forgeNoopImageDoc"}, operationDocs[i]); + IDLParserContext{"DocumentSourceFindAndModifyImageLookup::_forgeNoopImageDoc"}, + operationDocs[i]); if (const auto imageType = op.getNeedsRetryImage()) { // This operation has a retry image. diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.cpp b/src/mongo/db/pipeline/document_source_graph_lookup.cpp index e42c6cbe027..26537b44cfd 100644 --- a/src/mongo/db/pipeline/document_source_graph_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_graph_lookup.cpp @@ -78,7 +78,8 @@ NamespaceString parseGraphLookupFromAndResolveNamespace(const BSONElement& elem, } // Valdate the db and coll names. - auto spec = NamespaceSpec::parse({elem.fieldNameStringData()}, elem.embeddedObject()); + auto spec = + NamespaceSpec::parse(IDLParserContext{elem.fieldNameStringData()}, elem.embeddedObject()); // TODO SERVER-62491 Use system tenantId to construct nss. auto nss = NamespaceString(spec.getDb().value_or(""), spec.getColl().value_or("")); uassert(ErrorCodes::FailedToParse, diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp index e712caa02a7..b258c0f57c1 100644 --- a/src/mongo/db/pipeline/document_source_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_lookup.cpp @@ -105,7 +105,8 @@ NamespaceString parseLookupFromAndResolveNamespace(const BSONElement& elem, } // Valdate the db and coll names. - auto spec = NamespaceSpec::parse({elem.fieldNameStringData()}, elem.embeddedObject()); + auto spec = + NamespaceSpec::parse(IDLParserContext{elem.fieldNameStringData()}, elem.embeddedObject()); // TODO SERVER-62491 Use system tenantId to construct nss if running in serverless. auto nss = NamespaceString(spec.getDb().value_or(""), spec.getColl().value_or("")); uassert( diff --git a/src/mongo/db/pipeline/document_source_merge.cpp b/src/mongo/db/pipeline/document_source_merge.cpp index e881407df60..63e2aa38bde 100644 --- a/src/mongo/db/pipeline/document_source_merge.cpp +++ b/src/mongo/db/pipeline/document_source_merge.cpp @@ -287,7 +287,8 @@ DocumentSourceMergeSpec parseMergeSpecAndResolveTargetNamespace(const BSONElemen if (spec.type() == BSONType::String) { targetNss = {defaultDb, spec.valueStringData()}; } else { - mergeSpec = DocumentSourceMergeSpec::parse({kStageName}, spec.embeddedObject()); + mergeSpec = + DocumentSourceMergeSpec::parse(IDLParserContext{kStageName}, spec.embeddedObject()); targetNss = mergeSpec.getTargetNss(); if (targetNss.coll().empty()) { // If the $merge spec is an object, the target namespace can be specified as a string diff --git a/src/mongo/db/pipeline/document_source_merge_spec.cpp b/src/mongo/db/pipeline/document_source_merge_spec.cpp index f48de321d72..928874051f1 100644 --- a/src/mongo/db/pipeline/document_source_merge_spec.cpp +++ b/src/mongo/db/pipeline/document_source_merge_spec.cpp @@ -55,7 +55,8 @@ NamespaceString mergeTargetNssParseFromBSON(const BSONElement& elem) { return {"", elem.valueStringData()}; } - auto spec = NamespaceSpec::parse({elem.fieldNameStringData()}, elem.embeddedObject()); + auto spec = + NamespaceSpec::parse(IDLParserContext{elem.fieldNameStringData()}, elem.embeddedObject()); auto coll = spec.getColl(); uassert(5786801, "{} 'into' field must specify a 'coll' that is not empty, null or undefined"_format( diff --git a/src/mongo/db/query/collation/collator_factory_icu.cpp b/src/mongo/db/query/collation/collator_factory_icu.cpp index 499f19384d3..c0451909db0 100644 --- a/src/mongo/db/query/collation/collator_factory_icu.cpp +++ b/src/mongo/db/query/collation/collator_factory_icu.cpp @@ -261,7 +261,8 @@ Status updateCollationSpecFromICUCollator(const BSONObj& spec, try { // For backwards compatibility, "strength" is parsed from any int, long, or double. // Check it matches an enum value. - CollationStrength_parse({"collation.strength"}, collation->getStrength()); + CollationStrength_parse(IDLParserContext{"collation.strength"}, + collation->getStrength()); } catch (const DBException& exc) { return exc.toStatus(); } @@ -498,7 +499,7 @@ StatusWith<std::unique_ptr<CollatorInterface>> CollatorFactoryICU::makeFromBSON( Collation collation; try { - collation = Collation::parse({"collation"}, spec); + collation = Collation::parse(IDLParserContext{"collation"}, spec); } catch (const DBException& ex) { return ex.toStatus(); } diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index d04d0b8d736..f65648b7c24 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -549,11 +549,11 @@ public: auto ret = result->asTempObj(); if (ret[ErrorReply::kErrmsgFieldName].eoo()) { // Nominal success case, parse the object as-is. - HelloCommandReply::parse({"hello.reply"}, ret); + HelloCommandReply::parse(IDLParserContext{"hello.reply"}, ret); } else { // Something went wrong, still try to parse, but accept a few ignorable fields. StringDataSet ignorable({ErrorReply::kCodeFieldName, ErrorReply::kErrmsgFieldName}); - HelloCommandReply::parse({"hello.reply"}, ret.removeFields(ignorable)); + HelloCommandReply::parse(IDLParserContext{"hello.reply"}, ret.removeFields(ignorable)); } } diff --git a/src/mongo/db/s/resharding/document_source_resharding_ownership_match.cpp b/src/mongo/db/s/resharding/document_source_resharding_ownership_match.cpp index 00421dabd5a..51381f3622e 100644 --- a/src/mongo/db/s/resharding/document_source_resharding_ownership_match.cpp +++ b/src/mongo/db/s/resharding/document_source_resharding_ownership_match.cpp @@ -65,7 +65,7 @@ DocumentSourceReshardingOwnershipMatch::createFromBson( elem.type() == Object); auto parsed = DocumentSourceReshardingOwnershipMatchSpec::parse( - {"DocumentSourceReshardingOwnershipMatchSpec"}, elem.embeddedObject()); + IDLParserContext{"DocumentSourceReshardingOwnershipMatchSpec"}, elem.embeddedObject()); return new DocumentSourceReshardingOwnershipMatch( parsed.getRecipientShardId(), ShardKeyPattern(parsed.getReshardingKey()), expCtx); diff --git a/src/mongo/db/s/resharding/resharding_agg_test.cpp b/src/mongo/db/s/resharding/resharding_agg_test.cpp index 88e243a27bf..dfdaf0f18e9 100644 --- a/src/mongo/db/s/resharding/resharding_agg_test.cpp +++ b/src/mongo/db/s/resharding/resharding_agg_test.cpp @@ -1621,7 +1621,8 @@ TEST_F(ReshardingAggWithStorageTest, auto operationDocs = applyOpsInfo.getOperations(); ASSERT_EQ(operationDocs.size(), 1U); auto outputInnerOp2 = repl::DurableReplOperation::parse( - {"RetryableFindAndModifyInsideInternalTransactionWithImageLookup"}, operationDocs[0]); + IDLParserContext{"RetryableFindAndModifyInsideInternalTransactionWithImageLookup"}, + operationDocs[0]); ASSERT_TRUE(outputInnerOp2.getPreImageOpTime()); ASSERT_FALSE(outputInnerOp2.getNeedsRetryImage()); ASSERT_EQ(preImageOplog.getOpTime(), *outputInnerOp2.getPreImageOpTime()); @@ -1645,7 +1646,7 @@ TEST_F(ReshardingAggWithStorageTest, // Create another pipeline and start fetching from after the doc for the pre-image, and verify // that the pipeline does not re-output the applyOps doc that comes before the pre-image doc. const auto startAt = ReshardingDonorOplogId::parse( - {"RetryableFindAndModifyInsideInternalTransactionWithImageLookup"}, + IDLParserContext{"RetryableFindAndModifyInsideInternalTransactionWithImageLookup"}, preImageOplog.get_id()->getDocument().toBson()); auto newPipeline = createPipeline(startAt); diff --git a/src/mongo/db/s/resharding/resharding_data_replication.cpp b/src/mongo/db/s/resharding/resharding_data_replication.cpp index ff7bc064939..9704ecc8c98 100644 --- a/src/mongo/db/s/resharding/resharding_data_replication.cpp +++ b/src/mongo/db/s/resharding/resharding_data_replication.cpp @@ -460,7 +460,7 @@ ReshardingDonorOplogId ReshardingDataReplication::getOplogFetcherResumeId( return ReshardingOplogFetcher::kFinalOpAlreadyFetched; } - return ReshardingDonorOplogId::parse({"getOplogFetcherResumeId"}, + return ReshardingDonorOplogId::parse(IDLParserContext{"getOplogFetcherResumeId"}, oplogEntry.get_id()->getDocument().toBson()); } } diff --git a/src/mongo/db/s/resharding/resharding_donor_service.cpp b/src/mongo/db/s/resharding/resharding_donor_service.cpp index 60dc0170b0b..055666cf05d 100644 --- a/src/mongo/db/s/resharding/resharding_donor_service.cpp +++ b/src/mongo/db/s/resharding/resharding_donor_service.cpp @@ -204,7 +204,7 @@ std::shared_ptr<repl::PrimaryOnlyService::Instance> ReshardingDonorService::cons BSONObj initialState) { return std::make_shared<DonorStateMachine>( this, - ReshardingDonorDocument::parse({"DonorStateMachine"}, initialState), + ReshardingDonorDocument::parse(IDLParserContext{"DonorStateMachine"}, initialState), std::make_unique<ExternalStateImpl>(), _serviceContext); } 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 4479d5b18ce..9a4e90a7197 100644 --- a/src/mongo/db/s/resharding/resharding_donor_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_donor_service_test.cpp @@ -109,7 +109,8 @@ public: std::shared_ptr<PrimaryOnlyService::Instance> constructInstance(BSONObj initialState) override { return std::make_shared<DonorStateMachine>( this, - ReshardingDonorDocument::parse({"ReshardingDonorServiceForTest"}, initialState), + ReshardingDonorDocument::parse(IDLParserContext{"ReshardingDonorServiceForTest"}, + initialState), std::make_unique<ExternalStateForTest>(), _serviceContext); } diff --git a/src/mongo/db/s/resharding/resharding_oplog_applier.cpp b/src/mongo/db/s/resharding/resharding_oplog_applier.cpp index 470b5b382d2..b81e262d0a3 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_applier.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_applier.cpp @@ -227,9 +227,9 @@ boost::optional<ReshardingOplogApplierProgress> ReshardingOplogApplier::checkSto void ReshardingOplogApplier::_clearAppliedOpsAndStoreProgress(OperationContext* opCtx) { const auto& lastOplog = _currentBatchToApply.back(); - auto oplogId = - ReshardingDonorOplogId::parse({"ReshardingOplogApplier::_clearAppliedOpsAndStoreProgress"}, - lastOplog.get_id()->getDocument().toBson()); + auto oplogId = ReshardingDonorOplogId::parse( + IDLParserContext{"ReshardingOplogApplier::_clearAppliedOpsAndStoreProgress"}, + lastOplog.get_id()->getDocument().toBson()); PersistentTaskStore<ReshardingOplogApplierProgress> store( NamespaceString::kReshardingApplierProgressNamespace); diff --git a/src/mongo/db/s/resharding/resharding_oplog_batch_preparer.cpp b/src/mongo/db/s/resharding/resharding_oplog_batch_preparer.cpp index 95240e60907..8f9afdce99c 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_batch_preparer.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_batch_preparer.cpp @@ -140,7 +140,9 @@ WriterVectors ReshardingOplogBatchPreparer::makeCrudOpWriterVectors( for (const auto& innerOp : applyOpsInfo.getOperations()) { unrolledOp.setDurableReplOperation(repl::DurableReplOperation::parse( - {"ReshardingOplogBatchPreparer::makeCrudOpWriterVectors innerOp"}, innerOp)); + IDLParserContext{ + "ReshardingOplogBatchPreparer::makeCrudOpWriterVectors innerOp"}, + innerOp)); if (isWouldChangeOwningShardSentinelOplogEntry(unrolledOp)) { continue; @@ -230,7 +232,8 @@ WriterVectors ReshardingOplogBatchPreparer::makeSessionOpWriterVectors( for (const auto& innerOp : applyOpsInfo.getOperations()) { auto replOp = repl::ReplOperation::parse( - {"ReshardingOplogBatchPreparer::makeSessionOpWriterVectors innerOp"}, + IDLParserContext{ + "ReshardingOplogBatchPreparer::makeSessionOpWriterVectors innerOp"}, innerOp); if (replOp.getStatementIds().empty()) { // Skip this operation since it is not retryable. diff --git a/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp index 8172673e578..437540edb76 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp @@ -241,7 +241,7 @@ public: for (const auto& innerOp : applyOpsInfo.getOperations()) { operations.emplace_back(repl::DurableReplOperation::parse( - {"findApplyOpsNewerThan"}, innerOp)); + IDLParserContext{"findApplyOpsNewerThan"}, innerOp)); } result.emplace_back( diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp index 20685f612ab..8d85e96d61a 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp @@ -344,8 +344,9 @@ bool ReshardingOplogFetcher::consume(Client* client, WriteUnitOfWork wuow(opCtx); auto nextOplog = uassertStatusOK(repl::OplogEntry::parse(doc)); - auto startAt = ReshardingDonorOplogId::parse( - {"OplogFetcherParsing"}, nextOplog.get_id()->getDocument().toBson()); + auto startAt = + ReshardingDonorOplogId::parse(IDLParserContext{"OplogFetcherParsing"}, + nextOplog.get_id()->getDocument().toBson()); Timer insertTimer; uassertStatusOK(collection_internal::insertDocument( opCtx, *toWriteTo, InsertStatement{doc}, nullptr)); diff --git a/src/mongo/db/s/resharding/resharding_oplog_session_application.cpp b/src/mongo/db/s/resharding/resharding_oplog_session_application.cpp index ea59c3b1253..8471b6586bf 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_session_application.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_session_application.cpp @@ -138,7 +138,7 @@ boost::optional<SharedSemiFuture<void>> ReshardingOplogSessionApplication::tryAp isRetryableWrite ? op.getStatementIds() : std::vector<StmtId>{kIncompleteHistoryStmtId}; invariant(!stmtIds.empty()); - auto opId = ReshardingDonorOplogId::parse({"ReshardingOplogSessionApplication"}, + auto opId = ReshardingDonorOplogId::parse(IDLParserContext{"ReshardingOplogSessionApplication"}, op.get_id()->getDocument().toBson()); boost::optional<repl::OpTime> preImageOpTime; diff --git a/src/mongo/db/s/resharding/resharding_recipient_service.cpp b/src/mongo/db/s/resharding/resharding_recipient_service.cpp index 17d987114ad..5d2b5f8bcdf 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service.cpp @@ -178,7 +178,7 @@ std::shared_ptr<repl::PrimaryOnlyService::Instance> ReshardingRecipientService:: BSONObj initialState) { return std::make_shared<RecipientStateMachine>( this, - ReshardingRecipientDocument::parse({"RecipientStateMachine"}, initialState), + ReshardingRecipientDocument::parse(IDLParserContext{"RecipientStateMachine"}, initialState), std::make_unique<RecipientStateMachineExternalStateImpl>(), ReshardingDataReplication::make, _serviceContext); 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 b9809f93d89..32eeadff416 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp @@ -203,7 +203,8 @@ public: BSONObj initialState) override { return std::make_shared<RecipientStateMachine>( this, - ReshardingRecipientDocument::parse({"ReshardingRecipientServiceForTest"}, initialState), + ReshardingRecipientDocument::parse( + IDLParserContext{"ReshardingRecipientServiceForTest"}, initialState), std::make_unique<ExternalStateForTest>(), [](auto...) { return std::make_unique<DataReplicationForTest>(); }, _serviceContext); diff --git a/src/mongo/db/s/resharding/resharding_service_test_helpers.cpp b/src/mongo/db/s/resharding/resharding_service_test_helpers.cpp index b46f2a04178..2fae639c187 100644 --- a/src/mongo/db/s/resharding/resharding_service_test_helpers.cpp +++ b/src/mongo/db/s/resharding/resharding_service_test_helpers.cpp @@ -138,7 +138,8 @@ void OpObserverForTest<StateEnum, ReshardingDocument>::onUpdate(OperationContext return; } - auto doc = ReshardingDocument::parse({"OpObserverForTest"}, args.updateArgs->updatedDoc); + auto doc = ReshardingDocument::parse(IDLParserContext{"OpObserverForTest"}, + args.updateArgs->updatedDoc); _controller->_notifyNewStateAndWaitUntilUnpaused(opCtx, getState(doc)); } diff --git a/src/mongo/db/s/resharding/resharding_txn_cloner.cpp b/src/mongo/db/s/resharding/resharding_txn_cloner.cpp index 2062ed99402..e8f98fb3619 100644 --- a/src/mongo/db/s/resharding/resharding_txn_cloner.cpp +++ b/src/mongo/db/s/resharding/resharding_txn_cloner.cpp @@ -161,7 +161,8 @@ boost::optional<SessionTxnRecord> ReshardingTxnCloner::_getNextRecord(OperationC ON_BLOCK_EXIT([curOp] { curOp->done(); }); auto doc = pipeline.getNext(); - return doc ? SessionTxnRecord::parse({"resharding config.transactions cloning"}, doc->toBson()) + return doc ? SessionTxnRecord::parse(IDLParserContext{"resharding config.transactions cloning"}, + doc->toBson()) : boost::optional<SessionTxnRecord>{}; } diff --git a/src/mongo/db/s/session_catalog_migration_source.cpp b/src/mongo/db/s/session_catalog_migration_source.cpp index 40f93318f26..a564e5fd649 100644 --- a/src/mongo/db/s/session_catalog_migration_source.cpp +++ b/src/mongo/db/s/session_catalog_migration_source.cpp @@ -440,7 +440,8 @@ void SessionCatalogMigrationSource::_extractOplogEntriesForInternalTransactionFo for (const auto& innerOp : applyOpsInfo.getOperations()) { auto replOp = repl::ReplOperation::parse( - {"SessionOplogIterator::_extractOplogEntriesForInternalTransactionForRetryableWrite"}, + IDLParserContext{"SessionOplogIterator::_" + "extractOplogEntriesForInternalTransactionForRetryableWrite"}, innerOp); if (replOp.getStatementIds().empty()) { diff --git a/src/mongo/db/serverless/shard_split_donor_op_observer_test.cpp b/src/mongo/db/serverless/shard_split_donor_op_observer_test.cpp index e7528b6c256..0c1a97ad495 100644 --- a/src/mongo/db/serverless/shard_split_donor_op_observer_test.cpp +++ b/src/mongo/db/serverless/shard_split_donor_op_observer_test.cpp @@ -150,7 +150,7 @@ protected: ShardSplitDonorDocument defaultStateDocument() const { return ShardSplitDonorDocument::parse( - {"donor.document"}, + IDLParserContext{"donor.document"}, BSON("_id" << _uuid << "tenantIds" << _tenantIds << "recipientTagName" << _recipientTagName << "recipientSetName" << _recipientSetName)); } 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 ed4b6c8a87d..3be1da351f4 100644 --- a/src/mongo/db/serverless/shard_split_donor_service_test.cpp +++ b/src/mongo/db/serverless/shard_split_donor_service_test.cpp @@ -393,7 +393,7 @@ protected: ShardSplitDonorDocument defaultStateDocument() const { return ShardSplitDonorDocument::parse( - {"donor.document"}, + IDLParserContext{"donor.document"}, BSON("_id" << _uuid << "tenantIds" << _tenantIds << "recipientTagName" << _recipientTagName << "recipientSetName" << _recipientSetName)); } diff --git a/src/mongo/db/serverless/shard_split_utils_test.cpp b/src/mongo/db/serverless/shard_split_utils_test.cpp index 6b68e1717be..0c85517c262 100644 --- a/src/mongo/db/serverless/shard_split_utils_test.cpp +++ b/src/mongo/db/serverless/shard_split_utils_test.cpp @@ -223,7 +223,7 @@ TEST(MakeSplitConfig, RecipientConfigValidationTest) { const std::string recipientConfigSetName{"newSet"}; auto statedoc = ShardSplitDonorDocument::parse( - {"donor.document"}, + IDLParserContext{"donor.document"}, BSON("_id" << UUID::gen() << "tenantIds" << tenantIds << "recipientTagName" << recipientTagName << "recipientSetName" << recipientSetName)); diff --git a/src/mongo/db/session_catalog_mongod.cpp b/src/mongo/db/session_catalog_mongod.cpp index 96e24cf4b41..e851ab6a53a 100644 --- a/src/mongo/db/session_catalog_mongod.cpp +++ b/src/mongo/db/session_catalog_mongod.cpp @@ -347,7 +347,7 @@ int removeExpiredTransactionSessionsFromDisk( int numReaped = 0; while (cursor->more()) { auto transactionSession = SessionsCollectionFetchResultIndividualResult::parse( - "TransactionSession"_sd, cursor->next()); + IDLParserContext{"TransactionSession"}, cursor->next()); const auto transactionSessionId = transactionSession.get_id(); if (expiredTransactionSessionIdsStillInUse.find(transactionSessionId) != diff --git a/src/mongo/db/sessions_collection.cpp b/src/mongo/db/sessions_collection.cpp index 528f3ab5c16..39ef5fcc8b7 100644 --- a/src/mongo/db/sessions_collection.cpp +++ b/src/mongo/db/sessions_collection.cpp @@ -239,8 +239,8 @@ LogicalSessionIdSet SessionsCollection::_doFindRemoved( repl::ReadConcernArgs::kLocal); auto swBatchResult = send(batchWithReadConcernLocal.obj()); - auto result = - SessionsCollectionFetchResult::parse("SessionsCollectionFetchResult"_sd, swBatchResult); + auto result = SessionsCollectionFetchResult::parse( + IDLParserContext{"SessionsCollectionFetchResult"}, swBatchResult); for (const auto& lsid : result.getCursor().getFirstBatch()) { removed.erase(lsid.get_id()); diff --git a/src/mongo/db/transaction/transaction_api_test.cpp b/src/mongo/db/transaction/transaction_api_test.cpp index d6a6175ca6c..1669995c946 100644 --- a/src/mongo/db/transaction/transaction_api_test.cpp +++ b/src/mongo/db/transaction/transaction_api_test.cpp @@ -214,7 +214,7 @@ private: namespace { LogicalSessionId getLsid(BSONObj obj) { - auto osi = OperationSessionInfo::parse("assertSessionIdMetadata"_sd, obj); + auto osi = OperationSessionInfo::parse(IDLParserContext{"assertSessionIdMetadata"}, obj); ASSERT(osi.getSessionId()); return *osi.getSessionId(); } diff --git a/src/mongo/db/views/resolved_view.cpp b/src/mongo/db/views/resolved_view.cpp index 7330ecc732b..77577aba02d 100644 --- a/src/mongo/db/views/resolved_view.cpp +++ b/src/mongo/db/views/resolved_view.cpp @@ -76,8 +76,8 @@ ResolvedView ResolvedView::fromBSON(const BSONObj& commandResponseObj) { boost::optional<TimeseriesOptions> timeseriesOptions = boost::none; if (auto tsOptionsElt = viewDef[kTimeseriesOptions]) { if (tsOptionsElt.isABSONObj()) { - timeseriesOptions = - TimeseriesOptions::parse({"ResolvedView::fromBSON"}, tsOptionsElt.Obj()); + timeseriesOptions = TimeseriesOptions::parse(IDLParserContext{"ResolvedView::fromBSON"}, + tsOptionsElt.Obj()); } } diff --git a/src/mongo/db/write_concern_options.cpp b/src/mongo/db/write_concern_options.cpp index 02f4253a467..e99259f6b35 100644 --- a/src/mongo/db/write_concern_options.cpp +++ b/src/mongo/db/write_concern_options.cpp @@ -107,7 +107,7 @@ StatusWith<WriteConcernOptions> WriteConcernOptions::parse(const BSONObj& obj) t return Status(ErrorCodes::FailedToParse, "write concern object cannot be empty"); } - auto writeConcernIdl = WriteConcernIdl::parse({"WriteConcernOptions"}, obj); + auto writeConcernIdl = WriteConcernIdl::parse(IDLParserContext{"WriteConcernOptions"}, obj); auto parsedW = writeConcernIdl.getWriteConcernW(); WriteConcernOptions writeConcern; diff --git a/src/mongo/idl/idl_parser.h b/src/mongo/idl/idl_parser.h index d41122ce3bb..4b3d0ac46fa 100644 --- a/src/mongo/idl/idl_parser.h +++ b/src/mongo/idl/idl_parser.h @@ -238,7 +238,8 @@ public: static constexpr auto kOpMsgDollarDB = "$db"_sd; static constexpr auto kOpMsgDollarDBDefault = "admin"_sd; - IDLParserContext(StringData fieldName, bool apiStrict = false) + explicit IDLParserContext(StringData fieldName) : IDLParserContext{fieldName, false} {} + IDLParserContext(StringData fieldName, bool apiStrict) : _currentField(fieldName), _apiStrict(apiStrict), _predecessor(nullptr) {} IDLParserContext(StringData fieldName, const IDLParserContext* predecessor) diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp index 879c70ae177..32467123b21 100644 --- a/src/mongo/idl/idl_test.cpp +++ b/src/mongo/idl/idl_test.cpp @@ -162,7 +162,7 @@ void TestLoopback(TestT test_value) { auto element = testDoc.firstElement(); ASSERT_EQUALS(element.type(), Test_bson_type); - auto testStruct = ParserT::parse({"test"}, testDoc); + auto testStruct = ParserT::parse(IDLParserContext{"test"}, testDoc); assert_same_types<decltype(testStruct.getValue()), TestT>(); // We need to use a different unittest macro for comparing obj/array. @@ -393,7 +393,7 @@ TEST(IDLOneTypeTests, TestBase64StringPositive) { << "ABCD+/0=" << "url" << "1234-_0"); - auto parsed = Two_base64string::parse({"base64"}, doc); + auto parsed = Two_base64string::parse(IDLParserContext{"base64"}, doc); ASSERT_EQ(parsed.getBasic(), "\x00\x10\x83\xFB\xFD"_sd); ASSERT_EQ(parsed.getUrl(), "\xD7m\xF8\xFB\xFD"_sd); @@ -410,8 +410,10 @@ TEST(IDLOneTypeTests, TestBase64StringNegative) { << "ABCD+/0" << "url" << "1234-_0"); - ASSERT_THROWS_CODE_AND_WHAT( - Two_base64string::parse({"base64"}, doc), AssertionException, 10270, "invalid base64"); + ASSERT_THROWS_CODE_AND_WHAT(Two_base64string::parse(IDLParserContext{"base64"}, doc), + AssertionException, + 10270, + "invalid base64"); } { @@ -420,7 +422,7 @@ TEST(IDLOneTypeTests, TestBase64StringNegative) { << "ABCD+_0=" << "url" << "1234-_0"); - ASSERT_THROWS_CODE_AND_WHAT(Two_base64string::parse({"base64"}, doc), + ASSERT_THROWS_CODE_AND_WHAT(Two_base64string::parse(IDLParserContext{"base64"}, doc), AssertionException, 40537, "Invalid base64 character"); @@ -432,7 +434,7 @@ TEST(IDLOneTypeTests, TestBase64StringNegative) { << "ABCD+/0=" << "url" << "1234-/0"); - ASSERT_THROWS_CODE_AND_WHAT(Two_base64string::parse({"base64"}, doc), + ASSERT_THROWS_CODE_AND_WHAT(Two_base64string::parse(IDLParserContext{"base64"}, doc), AssertionException, 40537, "Invalid base64 character"); @@ -647,7 +649,7 @@ TEST(IDLVariantTests, TestVariantTwoArrays) { // This variant can be array<int> or array<string>. It assumes an empty array is array<int> // because that type is declared first in the IDL. auto obj = BSON("value" << BSONArray()); - auto parsed = One_variant_two_arrays::parse({"root"}, obj); + auto parsed = One_variant_two_arrays::parse(IDLParserContext{"root"}, obj); ASSERT(stdx::get<std::vector<int>>(parsed.getValue()) == std::vector<int>()); ASSERT_THROWS(stdx::get<std::vector<std::string>>(parsed.getValue()), stdx::bad_variant_access); @@ -658,14 +660,15 @@ TEST(IDLVariantTests, TestVariantTwoArrays) { arrayBob.append("1", "test_value"); } - ASSERT_THROWS_CODE( - One_variant_two_arrays::parse({"root"}, bob.obj()), AssertionException, 40423); + ASSERT_THROWS_CODE(One_variant_two_arrays::parse(IDLParserContext{"root"}, bob.obj()), + AssertionException, + 40423); } TEST(IDLVariantTests, TestVariantOptional) { { auto obj = BSON("value" << 1); - auto parsed = One_variant_optional::parse({"root"}, obj); + auto parsed = One_variant_optional::parse(IDLParserContext{"root"}, obj); ASSERT_BSONOBJ_EQ(obj, parsed.toBSON()); ASSERT_EQ(stdx::get<int>(*parsed.getValue()), 1); } @@ -673,13 +676,13 @@ TEST(IDLVariantTests, TestVariantOptional) { { auto obj = BSON("value" << "test_value"); - auto parsed = One_variant_optional::parse({"root"}, obj); + auto parsed = One_variant_optional::parse(IDLParserContext{"root"}, obj); ASSERT_BSONOBJ_EQ(obj, parsed.toBSON()); ASSERT_EQ(stdx::get<std::string>(*parsed.getValue()), "test_value"); } // The optional key is absent. - auto parsed = One_variant_optional::parse({"root"}, BSONObj()); + auto parsed = One_variant_optional::parse(IDLParserContext{"root"}, BSONObj()); ASSERT_FALSE(parsed.getValue().has_value()); ASSERT_BSONOBJ_EQ(BSONObj(), parsed.toBSON()); } @@ -689,7 +692,7 @@ TEST(IDLVariantTests, TestTwoVariants) { // parse(), toBSON(), getValue0(), getValue1(), and the constructor. { auto obj = BSON("value0" << 1 << "value1" << BSONObj()); - auto parsed = Two_variants::parse({"root"}, obj); + auto parsed = Two_variants::parse(IDLParserContext{"root"}, obj); ASSERT_BSONOBJ_EQ(obj, parsed.toBSON()); ASSERT_EQ(stdx::get<int>(parsed.getValue0()), 1); ASSERT_BSONOBJ_EQ(stdx::get<BSONObj>(parsed.getValue1()), BSONObj()); @@ -700,7 +703,7 @@ TEST(IDLVariantTests, TestTwoVariants) { auto obj = BSON("value0" << "test_value" << "value1" << BSONObj()); - auto parsed = Two_variants::parse({"root"}, obj); + auto parsed = Two_variants::parse(IDLParserContext{"root"}, obj); ASSERT_BSONOBJ_EQ(obj, parsed.toBSON()); ASSERT_EQ(stdx::get<std::string>(parsed.getValue0()), "test_value"); ASSERT_BSONOBJ_EQ(stdx::get<BSONObj>(parsed.getValue1()), BSONObj()); @@ -711,7 +714,7 @@ TEST(IDLVariantTests, TestTwoVariants) { auto obj = BSON("value0" << 1 << "value1" << BSON_ARRAY("x" << "y")); - auto parsed = Two_variants::parse({"root"}, obj); + auto parsed = Two_variants::parse(IDLParserContext{"root"}, obj); ASSERT_BSONOBJ_EQ(obj, parsed.toBSON()); ASSERT_EQ(stdx::get<int>(parsed.getValue0()), 1); ASSERT(stdx::get<std::vector<std::string>>(parsed.getValue1()) == @@ -725,7 +728,7 @@ TEST(IDLVariantTests, TestTwoVariants) { << "value1" << BSON_ARRAY("x" << "y")); - auto parsed = Two_variants::parse({"root"}, obj); + auto parsed = Two_variants::parse(IDLParserContext{"root"}, obj); ASSERT_BSONOBJ_EQ(obj, parsed.toBSON()); ASSERT_EQ(stdx::get<std::string>(parsed.getValue0()), "test_value"); ASSERT(stdx::get<std::vector<std::string>>(parsed.getValue1()) == @@ -4079,7 +4082,7 @@ TEST(IDLFieldTests, TenantOverrideField) { // Test optionality of $tenant arg. { - auto obj = BasicIgnoredCommand::parse({"nil"}, mkdoc(boost::none)); + auto obj = BasicIgnoredCommand::parse(IDLParserContext{"nil"}, mkdoc(boost::none)); auto tenant = obj.getDollarTenant(); ASSERT(tenant == boost::none); } @@ -4087,7 +4090,7 @@ TEST(IDLFieldTests, TenantOverrideField) { // Test passing an tenant id (acting on behalf of a specific tenant) { auto id = TenantId(OID::gen()); - auto obj = BasicIgnoredCommand::parse({"oid"}, mkdoc(id)); + auto obj = BasicIgnoredCommand::parse(IDLParserContext{"oid"}, mkdoc(id)); auto tenant = obj.getDollarTenant(); ASSERT(tenant == id); } @@ -4106,10 +4109,13 @@ TEST(IDLFieldTests, TenantOverrideFieldWithInvalidValue) { // Negative: Parse invalid types. { - ASSERT_THROWS(BasicIgnoredCommand::parse({"int"}, mkdoc(123)), DBException); - ASSERT_THROWS(BasicIgnoredCommand::parse({"float"}, mkdoc(3.14)), DBException); - ASSERT_THROWS(BasicIgnoredCommand::parse({"string"}, mkdoc("bar")), DBException); - ASSERT_THROWS(BasicIgnoredCommand::parse({"object"}, mkdoc(BSONObj())), DBException); + ASSERT_THROWS(BasicIgnoredCommand::parse(IDLParserContext{"int"}, mkdoc(123)), DBException); + ASSERT_THROWS(BasicIgnoredCommand::parse(IDLParserContext{"float"}, mkdoc(3.14)), + DBException); + ASSERT_THROWS(BasicIgnoredCommand::parse(IDLParserContext{"string"}, mkdoc("bar")), + DBException); + ASSERT_THROWS(BasicIgnoredCommand::parse(IDLParserContext{"object"}, mkdoc(BSONObj())), + DBException); } } diff --git a/src/mongo/idl/server_parameter_with_storage.h b/src/mongo/idl/server_parameter_with_storage.h index 38ad060a016..7db27ba1291 100644 --- a/src/mongo/idl/server_parameter_with_storage.h +++ b/src/mongo/idl/server_parameter_with_storage.h @@ -428,7 +428,7 @@ public: if constexpr (paramType == SPT::kClusterWide) { try { BSONObj cspObj = newValueElement.Obj(); - newValue = element_type::parse({"ClusterServerParameter"}, cspObj); + newValue = element_type::parse(IDLParserContext{"ClusterServerParameter"}, cspObj); } catch (const DBException& ex) { return ex.toStatus().withContext( str::stream() << "Failed parsing ClusterServerParameter '" << name() << "'"); diff --git a/src/mongo/rpc/write_concern_error_detail.cpp b/src/mongo/rpc/write_concern_error_detail.cpp index 78767dfe43e..9e61408586e 100644 --- a/src/mongo/rpc/write_concern_error_detail.cpp +++ b/src/mongo/rpc/write_concern_error_detail.cpp @@ -82,7 +82,7 @@ bool WriteConcernErrorDetail::parseBSON(const BSONObj& source, string* errMsg) { errMsg = &dummy; try { - auto wce = WriteConcernError::parse({"writeConcernError"}, source); + auto wce = WriteConcernError::parse(IDLParserContext{"writeConcernError"}, source); _status = Status(ErrorCodes::Error(wce.getCode()), wce.getErrmsg(), source); if ((_isErrInfoSet = wce.getErrInfo().has_value())) { _errInfo = wce.getErrInfo().value().getOwned(); diff --git a/src/mongo/s/commands/cluster_data_size_cmd.cpp b/src/mongo/s/commands/cluster_data_size_cmd.cpp index 948f8543dda..32e5ff6140c 100644 --- a/src/mongo/s/commands/cluster_data_size_cmd.cpp +++ b/src/mongo/s/commands/cluster_data_size_cmd.cpp @@ -102,7 +102,7 @@ public: const auto& res = shardResponse.data; uassertStatusOK(getStatusFromCommandResult(res)); - auto parsedResponse = Reply::parse({"dataSize"}, res); + auto parsedResponse = Reply::parse(IDLParserContext{"dataSize"}, res); size += parsedResponse.getSize(); numObjects += parsedResponse.getNumObjects(); millis += parsedResponse.getMillis(); diff --git a/src/mongo/s/commands/cluster_db_stats_cmd.cpp b/src/mongo/s/commands/cluster_db_stats_cmd.cpp index 1f130939099..6e4674b4c5b 100644 --- a/src/mongo/s/commands/cluster_db_stats_cmd.cpp +++ b/src/mongo/s/commands/cluster_db_stats_cmd.cpp @@ -59,7 +59,7 @@ void aggregateResults(int scale, for (const auto& response : responses) { invariant(response.swResponse.getStatus().isOK()); const BSONObj& b = response.swResponse.getValue().data; - auto resp = DBStats::parse({"dbstats"}, b); + auto resp = DBStats::parse(IDLParserContext{"dbstats"}, b); collections += resp.getCollections(); views += resp.getViews(); @@ -149,7 +149,7 @@ public: } void validateResult(const BSONObj& resultObj) final { - DBStats::parse({"dbstats.reply"}, resultObj); + DBStats::parse(IDLParserContext{"dbstats.reply"}, resultObj); } } clusterDBStatsCmd; diff --git a/src/mongo/s/commands/cluster_drop_collection_cmd.cpp b/src/mongo/s/commands/cluster_drop_collection_cmd.cpp index 12d3b138aaa..ef1bfe63c7b 100644 --- a/src/mongo/s/commands/cluster_drop_collection_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_collection_cmd.cpp @@ -117,7 +117,7 @@ public: auto resultObj = result.obj(); uassertStatusOK(getStatusFromCommandResult(resultObj)); // Ensure our reply conforms to the IDL-defined reply structure. - return DropReply::parse({"drop"}, resultObj); + return DropReply::parse(IDLParserContext{"drop"}, resultObj); } catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) { uassert(CollectionUUIDMismatchInfo(request().getDbName().toString(), *request().getCollectionUUID(), diff --git a/src/mongo/s/commands/cluster_fle2_compact_cmd.cpp b/src/mongo/s/commands/cluster_fle2_compact_cmd.cpp index b1cecbf555e..65b891e4c4c 100644 --- a/src/mongo/s/commands/cluster_fle2_compact_cmd.cpp +++ b/src/mongo/s/commands/cluster_fle2_compact_cmd.cpp @@ -110,7 +110,7 @@ Cmd::Reply Cmd::Invocation::typedRun(OperationContext* opCtx) { auto reply = result.obj(); uassertStatusOK(getStatusFromCommandResult(reply)); - return Reply::parse({Request::kCommandName}, reply.removeField("ok"_sd)); + return Reply::parse(IDLParserContext{Request::kCommandName}, reply.removeField("ok"_sd)); } } // namespace diff --git a/src/mongo/s/commands/cluster_getmore_cmd.h b/src/mongo/s/commands/cluster_getmore_cmd.h index 3fec3150c0b..85921bbc011 100644 --- a/src/mongo/s/commands/cluster_getmore_cmd.h +++ b/src/mongo/s/commands/cluster_getmore_cmd.h @@ -78,7 +78,7 @@ public: public: Invocation(Command* cmd, const OpMsgRequest& request) : CommandInvocation(cmd), - _cmd(GetMoreCommandRequest::parse({Impl::kName}, request.body)) {} + _cmd(GetMoreCommandRequest::parse(IDLParserContext{Impl::kName}, request.body)) {} private: NamespaceString ns() const override { @@ -115,7 +115,8 @@ public: } void validateResult(const BSONObj& replyObj) { - CursorGetMoreReply::parse({"CursorGetMoreReply"}, replyObj.removeField("ok")); + CursorGetMoreReply::parse(IDLParserContext{"CursorGetMoreReply"}, + replyObj.removeField("ok")); } const GetMoreCommandRequest _cmd; diff --git a/src/mongo/s/commands/cluster_hello_cmd.cpp b/src/mongo/s/commands/cluster_hello_cmd.cpp index 6b958b00b9b..6842e81ca83 100644 --- a/src/mongo/s/commands/cluster_hello_cmd.cpp +++ b/src/mongo/s/commands/cluster_hello_cmd.cpp @@ -269,11 +269,11 @@ public: auto ret = result->asTempObj(); if (ret[ErrorReply::kErrmsgFieldName].eoo()) { // Nominal success case, parse the object as-is. - HelloCommandReply::parse({"hello.reply"}, ret); + HelloCommandReply::parse(IDLParserContext{"hello.reply"}, ret); } else { // Something went wrong, still try to parse, but accept a few ignorable fields. StringDataSet ignorable({ErrorReply::kCodeFieldName, ErrorReply::kErrmsgFieldName}); - HelloCommandReply::parse({"hello.reply"}, ret.removeFields(ignorable)); + HelloCommandReply::parse(IDLParserContext{"hello.reply"}, ret.removeFields(ignorable)); } } diff --git a/src/mongo/s/commands/cluster_list_indexes_cmd.cpp b/src/mongo/s/commands/cluster_list_indexes_cmd.cpp index 047511473bf..44cbdde7854 100644 --- a/src/mongo/s/commands/cluster_list_indexes_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_indexes_cmd.cpp @@ -74,7 +74,7 @@ ListIndexesReply cursorCommandPassthroughShardWithMinKeyChunk(OperationContext* const auto& resultObj = out.obj(); uassertStatusOK(getStatusFromCommandResult(resultObj)); // The reply syntax must conform to its IDL definition. - return ListIndexesReply::parse({"listIndexes"}, resultObj); + return ListIndexesReply::parse(IDLParserContext{"listIndexes"}, resultObj); } class CmdListIndexes final : public ListIndexesCmdVersion1Gen<CmdListIndexes> { diff --git a/src/mongo/s/query/async_results_merger_test.cpp b/src/mongo/s/query/async_results_merger_test.cpp index ef7817b0961..fd5be3317f9 100644 --- a/src/mongo/s/query/async_results_merger_test.cpp +++ b/src/mongo/s/query/async_results_merger_test.cpp @@ -1110,7 +1110,7 @@ TEST_F(AsyncResultsMergerTest, GetMoreBatchSizes) { readyEvent = unittest::assertGet(arm->nextEvent()); BSONObj scheduledCmd = getNthPendingRequest(0).cmdObj; - auto cmd = GetMoreCommandRequest::parse({"getMore"}, + auto cmd = GetMoreCommandRequest::parse(IDLParserContext{"getMore"}, scheduledCmd.addField(BSON("$db" << "anydbname") .firstElement())); diff --git a/src/mongo/s/sharding_task_executor.cpp b/src/mongo/s/sharding_task_executor.cpp index 0dbfb54a762..fd6b4e02f12 100644 --- a/src/mongo/s/sharding_task_executor.cpp +++ b/src/mongo/s/sharding_task_executor.cpp @@ -136,8 +136,8 @@ StatusWith<TaskExecutor::CallbackHandle> ShardingTaskExecutor::scheduleRemoteCom } if (request.cmdObj.hasField("lsid")) { - auto cmdObjLsid = - LogicalSessionFromClient::parse("lsid"_sd, request.cmdObj["lsid"].Obj()); + auto cmdObjLsid = LogicalSessionFromClient::parse(IDLParserContext{"lsid"}, + request.cmdObj["lsid"].Obj()); if (cmdObjLsid.getUid()) { invariant(*cmdObjLsid.getUid() == request.opCtx->getLogicalSessionId()->getUid()); diff --git a/src/mongo/s/sharding_task_executor_test.cpp b/src/mongo/s/sharding_task_executor_test.cpp index ac776832486..ac9ef0ad86e 100644 --- a/src/mongo/s/sharding_task_executor_test.cpp +++ b/src/mongo/s/sharding_task_executor_test.cpp @@ -76,7 +76,8 @@ protected: ASSERT(opCtxLsid); - auto cmdObjLsid = LogicalSessionFromClient::parse("lsid"_sd, cmdObj["lsid"].Obj()); + auto cmdObjLsid = + LogicalSessionFromClient::parse(IDLParserContext{"lsid"}, cmdObj["lsid"].Obj()); ASSERT_EQ(opCtxLsid->getId(), cmdObjLsid.getId()); ASSERT_EQ(opCtxLsid->getUid(), *cmdObjLsid.getUid()); diff --git a/src/mongo/s/transaction_router.cpp b/src/mongo/s/transaction_router.cpp index 13f5b23f24a..f2ab920aacc 100644 --- a/src/mongo/s/transaction_router.cpp +++ b/src/mongo/s/transaction_router.cpp @@ -473,8 +473,8 @@ BSONObj TransactionRouter::Participant::attachTxnFieldsIfNeeded( newCmd.append(OperationSessionInfo::kTxnNumberFieldName, sharedOptions.txnNumberAndRetryCounter.getTxnNumber()); } else { - auto osi = - OperationSessionInfoFromClient::parse("OperationSessionInfo"_sd, newCmd.asTempObj()); + auto osi = OperationSessionInfoFromClient::parse(IDLParserContext{"OperationSessionInfo"}, + newCmd.asTempObj()); invariant(sharedOptions.txnNumberAndRetryCounter.getTxnNumber() == *osi.getTxnNumber()); } @@ -515,7 +515,7 @@ void TransactionRouter::Router::processParticipantResponse(OperationContext* opC } auto txnResponseMetadata = - TxnResponseMetadata::parse("processParticipantResponse"_sd, responseObj); + TxnResponseMetadata::parse(IDLParserContext{"processParticipantResponse"}, responseObj); if (txnResponseMetadata.getReadOnly()) { if (participant->readOnly == Participant::ReadOnly::kUnset) { diff --git a/src/mongo/s/transaction_router_test.cpp b/src/mongo/s/transaction_router_test.cpp index 9b07a085c46..bee7dd7e673 100644 --- a/src/mongo/s/transaction_router_test.cpp +++ b/src/mongo/s/transaction_router_test.cpp @@ -164,8 +164,8 @@ protected: auto cmdName = request.cmdObj.firstElement().fieldNameStringData(); ASSERT_EQ(cmdName, "abortTransaction"); - auto osi = OperationSessionInfoFromClient::parse("expectAbortTransaction"_sd, - request.cmdObj); + auto osi = OperationSessionInfoFromClient::parse( + IDLParserContext{"expectAbortTransaction"}, request.cmdObj); ASSERT(osi.getSessionId()); ASSERT_EQ(lsid.getId(), osi.getSessionId()->getId()); @@ -1020,7 +1020,7 @@ void checkSessionDetails(const BSONObj& cmdObj, const LogicalSessionId& lsid, const TxnNumber txnNum, boost::optional<bool> isCoordinator) { - auto osi = OperationSessionInfoFromClient::parse("testTxnRouter"_sd, cmdObj); + auto osi = OperationSessionInfoFromClient::parse(IDLParserContext{"testTxnRouter"}, cmdObj); ASSERT(osi.getSessionId()); ASSERT_EQ(lsid.getId(), osi.getSessionId()->getId()); |