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

applyOps returns wrong error code when document validation fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.8
    • Component/s: Write Ops
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      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})); })();

      Description

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

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: