Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2959

"validate" option is passed in command

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 1.14.0
    • Affects Version/s: 1.10.3
    • Component/s: libmongoc
    • None

      I noticed the "validate" option had broken our performance tests on newer MongoDB.

      The "validate" option dictates whether or not we validate user supplied BSON documents before adding them to the relevant operation:

      However, this option appears to be broken. We must not send this as part of the command but it appears we do. A test like this fails:

      static void
      test_validate_option (void)
      {
         mongoc_client_t *client = test_framework_client_new ();
         mongoc_collection_t *coll =
            mongoc_client_get_collection (client, "db", "coll");
         bson_error_t error;
         bson_t reply;
         bool ret;
      
         /* Test setting "validate" for any set of options that take it. */
         mongoc_bulk_operation_t *bulk;
         bulk = mongoc_collection_create_bulk_operation (coll, false, NULL);
         ret = mongoc_bulk_operation_insert_with_opts (
            bulk,
            BCON_NEW ("x", BCON_INT32 (1)),
            BCON_NEW ("validate", BCON_INT32 (BSON_VALIDATE_DOLLAR_KEYS)),
            &error);
      
         ASSERT_OR_PRINT (ret, error);
      
         ret = mongoc_bulk_operation_execute (bulk, &reply, &error)
         ASSERT_OR_PRINT (ret, error);
      
         bson_destroy (&reply);
         mongoc_collection_destroy (coll);
         mongoc_client_destroy (client);
      }
      

      With an error message:

      Unknown option to insert command: validate
      

      I've confirmed with wireshark that we are sending "valildate" as part of the insert command, and that the server is generating this error.

      This seems to go back as far as 1.10 (possibly this was introduced in IDL parsing of CDRIVER-2373). Our existing validate tests don't seem to check the successful case, where we expect validation to succeed.

      It seems MongoDB 3.2 didn't care that we sent the extra "validate" option and just ignored it. But newer (at least 3.6, haven't checked 3.4) does.

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: