Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-21345

applyOps returns wrong error code when document validation fails

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.3.8
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • Storage Execution
    • Fully Compatible
    • ALL
    • Hide
      (function() { 
          'use strict';                                                                                   
                                                                                                          
          var dbName = 'bypass_document_validation';                                                      
          var collName = 'bypass_document_validation';                                                    
          var myDb = db.getSiblingDB(dbName);                                                             
          var coll = myDb[collName];                                                                      
          var docValidationErrorCode = ErrorCodes.DocumentValidationFailure;                              
          coll.drop();                                                                                    
                                                                                                          
          // Create a collection with a validation rule                                                   
          assert.commandWorked(myDb.runCommand({create: collName, validator: {a: {$exists: true}}}));                                                                                                         
          // Test applyOps with a simple insert                                                           
          var op = [{ts: Timestamp(0, 0), h: 1, v: 2, op: 'i', ns: coll.getFullName(), o: {_id: 1}}];     
          // applyOps is returning ErrorCodes.UnknownError (8) instead of DocumentValidationFailure  
          assert.commandFailedWithCode( 
              myDb.runCommand({applyOps: op, bypassDocumentValidation: false}), docValidationErrorCode        );                                                                                              
          assert.eq(0, coll.count({_id: 1}));                                                                                                    
      })(); 
      
      Show
      (function() { 'use strict' ; var dbName = 'bypass_document_validation' ; var collName = 'bypass_document_validation' ; var myDb = db.getSiblingDB(dbName); var coll = myDb[collName]; var docValidationErrorCode = ErrorCodes.DocumentValidationFailure; coll.drop(); // Create a collection with a validation rule assert .commandWorked(myDb.runCommand({create: collName, validator: {a: {$exists: true }}})); // Test applyOps with a simple insert var op = [{ts: Timestamp(0, 0), h: 1, v: 2, op: 'i' , ns: coll.getFullName(), o: {_id: 1}}]; // applyOps is returning ErrorCodes.UnknownError (8) instead of DocumentValidationFailure assert .commandFailedWithCode( myDb.runCommand({applyOps: op, bypassDocumentValidation: false }), docValidationErrorCode ); assert .eq(0, coll.count({_id: 1})); })();

      applyOps is returning ErrorCodes.UnknownError (8) instead of ErrorCodes.DocumentValidationFailure (121).

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            dan@mongodb.com Daniel Pasette (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: