summaryrefslogtreecommitdiff
path: root/src/mongo/db/update/storage_validation.cpp
diff options
context:
space:
mode:
authorAlya Berciu <alyacarina@gmail.com>2021-05-06 10:09:11 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-13 08:53:21 +0000
commitfe74857f35267a767de40da27ce5e67aa83f4bba (patch)
tree1c4abb9578072e2e8f7ace43fc2cba538e44b480 /src/mongo/db/update/storage_validation.cpp
parent952e709824d58eddff659c9ff31da69fa839470b (diff)
downloadmongo-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.cpp9
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