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: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability
    • Fully Compatible
    • 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);  
    • Programmability 2024-10-28

      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:
            adithi.raghavan@mongodb.com Adithi Raghavan
            Reporter:
            andrea.rahmanan@mongodb.com Andrea Rahmanan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: