[SERVER-43594] Report invalid IDL types during IDL parsing Created: 24/Sep/19  Updated: 27/Oct/23  Resolved: 11/Oct/19

Status: Closed
Project: Core Server
Component/s: IDL
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Maria van Keulen Assignee: Mark Benvenuto
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Security 2019-10-21
Participants:

 Description   

Presently, when a type is passed to IDL that isn't supported in BSON, the following cryptic compiler errors occur:

src/mongo/idl/server_parameter_with_storage.h:238:15: error: call to deleted member function 'append'
            b.append(name, getValue());
            ~~^~~~~~
src/mongo/idl/server_parameter_with_storage.h:192:5: note: in instantiation of member function 'mongo::IDLServerParameterWithStorage<mongo::ServerParameterType::kStartupOnly, unsigned long long>::append' requested here
    IDLServerParameterWithStorage(StringData name, T& storage)
    ^
src/mongo/idl/server_parameter_with_storage.h:325:16: note: in instantiation of member function 'mongo::IDLServerParameterWithStorage<mongo::ServerParameterType::kStartupOnly, unsigned long long>::IDLServerParameterWithStorage' requested here
    return new IDLServerParameterWithStorage<paramType, T>(name, storage);
               ...
src/mongo/idl/server_parameter_with_storage.h:251:30: error: no matching member function for call to 'coerce'
        if (!newValueElement.coerce(&newValue)) {
             ~~~~~~~~~~~~~~~~^~~~~~

Instead, we should add a more intuitive error message that mentions that this type isn't supported by BSON. One solution could be to identify these unsupported types at IDL parse time, and output the error there.



 Comments   
Comment by Mark Benvenuto [ 10/Oct/19 ]

Unfortunately, there is no way for the IDL to know apriori if a given C++ type is supported because only the C++ compiler knows. While we could add a whitelist of permitted types, there are more creative uses in the code then we could support with a whitelist. Below is an example of case which would not work with a 

Example:

$ git grep cpp_vartype *.idl
src/mongo/db/transaction_participant.idl:        cpp_vartype: AtomicWord<decltype(TransactionParticipant::observeTransactionLifetimeLimitSeconds)::Argument>

Comment by Maria van Keulen [ 09/Oct/19 ]

mark.benvenuto Sure thing. Here is one such snippet:

    minOplogTruncationPoints:
        description: 'Minimum allowable number of oplog truncation points'
        set_at: [ startup ]
        cpp_vartype: 'unsigned long long'
        cpp_varname: gMinOplogStones
        default: 10
        validator: { gt: 0 } 

Comment by Mark Benvenuto [ 09/Oct/19 ]

maria.vankeulen, can you provide an example of the IDL snippet that produced this C++ error.

Generated at Thu Feb 08 05:03:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.