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

IDL parser returns an unclear error message with wrong types

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability
    • ALL
    • Hide

      The issue can be reproduced by adding the following test to idl_test.cpp.

      const auto expectedWhat= "TypeMismatch: BSON field 'root.value' is the wrong type " "'object', expected types '[int, string]'";
       
      
      ASSERT_THROWS_CODE_AND_WHAT( One_variant::parse(IDLParserContext("root"), BSON("value"<<BSONObj())), AssertionException, ErrorCodes::TypeMismatch, expectedWhat);

       

      Show
      The issue can be reproduced by adding the following test to idl_test.cpp. const auto expectedWhat= "TypeMismatch: BSON field 'root.value' is the wrong type " " 'object' , expected types '[ int , string]' " ;   ASSERT_THROWS_CODE_AND_WHAT( One_variant::parse(IDLParserContext( "root" ), BSON( "value" <<BSONObj())), AssertionException, ErrorCodes::TypeMismatch, expectedWhat);  

      When using "variant" the IDL parser returns an unclear error message when parsing an invalid type.  This issue can be reproduced within the idl_test.cpp file, which defines the following struct:

          one_variant:
              description: UnitTest for a single variant which accepts int or string
              strict: false
              fields:
                  value:
                      type:
                          variant: [int, string] 

       When setting the "value" field to an object type, the parser will throw the following error: "BSON field 'root.value' is the wrong type 'object', expected types '[']".

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            andrea.rahmanan@mongodb.com Andrea Rahmanan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: