[CDRIVER-1853] _mongoc_write_concern_iter_is_valid fails with write concern "majority" Created: 18/Oct/16  Updated: 19/Oct/16  Resolved: 19/Oct/16

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.4.0
Fix Version/s: 1.5.0

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Also doesn't recognize a tag set:

https://docs.mongodb.com/manual/reference/write-concern/



 Comments   
Comment by Githook User [ 19/Oct/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1853 _mongoc_write_concern_iter_is_valid fails with write concern "majority"
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/eb64540631ab2dde2b8b4885a505dc648cab9cdc

Comment by A. Jesse Jiryu Davis [ 18/Oct/16 ]

Beginning:

Date:   Tue Oct 18 16:15:08 2016 -0400
 
    On CDRIVER-1527-cmd-with-opts: fix write concern validate
 
diff --cc src/mongoc/mongoc-write-concern.c
index af3e8d5,af3e8d5..4d628af
--- a/src/mongoc/mongoc-write-concern.c
+++ b/src/mongoc/mongoc-write-concern.c
@@@ -624,12 -624,12 +624,15 @@@ _mongoc_write_concern_iter_is_valid (bs
           has_fsync = bson_iter_bool (&inner);
        }
        else if (BSON_ITER_IS_KEY (&inner, "w")) {
--         if (!BSON_ITER_HOLDS_INT32 (&inner)) {
--            return false;
--         }
--         if (bson_iter_int32 (&inner) == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED ||
--               bson_iter_int32 (&inner) == MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED) {
++         if (BSON_ITER_HOLDS_INT32 (&inner) &&
++            (bson_iter_int32 (&inner) == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED ||
++             bson_iter_int32 (&inner) == MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED)) {
              w0 = true;
++         } else if (BSON_ITER_HOLDS_UTF8 (&inner) ||
++                    BSON_ITER_HOLDS_DOCUMENT (&inner)) {
++            /* "majority" or tag sets or any future write concern name is ok */
++         } else {
++            return false;
           }
        }

Comment by A. Jesse Jiryu Davis [ 18/Oct/16 ]

Test with "majority", another string besides "majority", and with a tag set.

Generated at Wed Feb 07 21:13:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.