summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher
diff options
context:
space:
mode:
authorMindaugas Malinauskas <mindaugas.malinauskas@mongodb.com>2020-08-21 10:54:14 +0300
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-31 12:08:32 +0000
commitf5da4e4b7f7f04267bd92736ee9b16417e6d70ff (patch)
treef0ae8b67db601735b166dc1b592d21f4c92d7ad7 /src/mongo/db/matcher
parent1eb0308decd6709fe9d0df9212fa690cd20e03fd (diff)
downloadmongo-f5da4e4b7f7f04267bd92736ee9b16417e6d70ff.tar.gz
SERVER-49499 Upgrade/downgrade behavior and testing for generating document validation errors
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r--src/mongo/db/matcher/doc_validation_error.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/matcher/doc_validation_error.cpp b/src/mongo/db/matcher/doc_validation_error.cpp
index c5320f88bc5..bbc2f4eb1cb 100644
--- a/src/mongo/db/matcher/doc_validation_error.cpp
+++ b/src/mongo/db/matcher/doc_validation_error.cpp
@@ -974,6 +974,10 @@ bool hasErrorAnnotations(const MatchExpression& validatorExpr) {
} // namespace
std::shared_ptr<const ErrorExtraInfo> DocumentValidationFailureInfo::parse(const BSONObj& obj) {
+ if (!obj.hasField("errInfo"_sd)) {
+ // TODO SERVER-50524: remove this block when 5.0 becomes last-lts.
+ return nullptr;
+ }
auto errInfo = obj["errInfo"];
uassert(4878100,
"DocumentValidationFailureInfo must have a field 'errInfo' of type object",
@@ -993,7 +997,9 @@ BSONObj generateError(const MatchExpression& validatorExpr, const BSONObj& doc)
ValidationErrorInVisitor inVisitor{&context};
ValidationErrorPostVisitor postVisitor{&context};
// TODO SERVER-49446: Once all nodes have ErrorAnnotations, this check should be converted to an
- // invariant check that all nodes have an annotation.
+ // invariant check that all nodes have an annotation. Also add an invariant to the
+ // DocumentValidationFailureInfo constructor to check that it is initialized with a non-empty
+ // object.
if (!hasErrorAnnotations(validatorExpr)) {
return BSONObj();
}