diff options
author | Alya Berciu <alyacarina@gmail.com> | 2021-05-06 10:09:11 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-13 08:53:21 +0000 |
commit | fe74857f35267a767de40da27ce5e67aa83f4bba (patch) | |
tree | 1c4abb9578072e2e8f7ace43fc2cba538e44b480 /src/mongo/db/update/storage_validation.cpp | |
parent | 952e709824d58eddff659c9ff31da69fa839470b (diff) | |
download | mongo-fe74857f35267a767de40da27ce5e67aa83f4bba.tar.gz |
SERVER-49118 Update error messages for operations that reject fieldnames with '.' and '$'
Diffstat (limited to 'src/mongo/db/update/storage_validation.cpp')
-rw-r--r-- | src/mongo/db/update/storage_validation.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/update/storage_validation.cpp b/src/mongo/db/update/storage_validation.cpp index 2199109e450..ffb70ff21ee 100644 --- a/src/mongo/db/update/storage_validation.cpp +++ b/src/mongo/db/update/storage_validation.cpp @@ -105,10 +105,15 @@ void validateDollarPrefixElement(mutablebson::ConstElement elem) { curr.rightSibling().ok() && curr.rightSibling().getFieldName() == "$id"); } else { // Not an okay, $ prefixed field name. + const auto replaceWithHint = + feature_flags::gFeatureFlagDotsAndDollars.isEnabledAndIgnoreFCV() + ? "' is not allowed in the context of an update's replacement document. Consider using " + "an aggregation pipeline with $replaceWith." + : "' is not valid for storage."; + uasserted(ErrorCodes::DollarPrefixedFieldName, str::stream() << "The dollar ($) prefixed field '" << elem.getFieldName() - << "' in '" << mutablebson::getFullName(elem) - << "' is not valid for storage."); + << "' in '" << mutablebson::getFullName(elem) << replaceWithHint); } } } // namespace |