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

applyOps returns wrong error code when document validation fails

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 3.3.8
    • Write Ops
    • None
    • 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})); })();

    Description

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

      Attachments

        Issue Links

          Activity

            People

              backlog-server-execution Backlog - Storage Execution Team
              dan@mongodb.com Daniel Pasette
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: