[SERVER-51653] Ban uses of unstable command parameters with apiStrict: true Created: 15/Oct/20  Updated: 29/Oct/23  Resolved: 02/Dec/20

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

Type: New Feature Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Arun Banala
Resolution: Fixed Votes: 0
Labels: qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-51378 Add "unstable" parameter field to IDL... Closed
is depended on by SERVER-51654 Validate unstable parameters in creat... Closed
is depended on by SERVER-52874 Implement validateDBMetadata command Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2020-11-30, Query 2020-12-14
Participants:

 Description   

In the "API Version Testing" project we added a boolean field "unstable" to mark command parameters in the IDL for API Version 1 commands. Unstable parameters are not guaranteed to be backward-compatible, even though they are parameters of V1 commands. We plan to use the "unstable" field only when comparing old and new releases' IDL definitions of V1 commands; we'll ignore incompatible changes to unstable fields.

However, arun.banala makes a good suggestion: at runtime, ban the use of unstable parameters in client requests that include apiStrict: true.



 Comments   
Comment by Githook User [ 02/Dec/20 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: SERVER-51653 Ban uses of unstable command parameters with apiStrict:true
Branch: master
https://github.com/mongodb/mongo/commit/6cf43fbc5c296c26ec03193c70c5fc3ba742c942

Comment by Steven Vannelli [ 19/Oct/20 ]

Thanks arun.banala. I'm adding this to that project and assigning it to the Query backlog user for now.

Comment by A. Jesse Jiryu Davis [ 15/Oct/20 ]

I'm not sure how to do this. The IDL compiler might generate code that checks for unstable parameters, e.g. from the following IDL:

commands:
  createIndexes:
    api_versions: ["1"]
    fields:
      experimental_field:
        type: int
        unstable: true

... we might generate:

class CreateIndexesRequest {
public:
    static CreateIndexesRequest parse(
        const IDLParserErrorContext& ctxt,
        const BSONObj& bsonObject,
        bool apiStrict /* NEW ARGUMENT */);
        
    // ... other IDL-generated code ...
};

Then in TypedCommand:

template <typename Derived>
class TypedCommand<Derived>::InvocationBaseInternal : public CommandInvocation {
public:
    using RequestType = typename Derived::Request;
 
    InvocationBaseInternal(OperationContext* opCtx /* ALREADY EXISTS */,
                           const Command* command,
                           const OpMsgRequest& opMsgRequest)
        : CommandInvocation(command), _request{_parseRequest(command->getName(), opMsgRequest, opCtx /* NEW */)} {}
 
private:
    static RequestType _parseRequest(
        StringData name,
        const OpMsgRequest& opMsgRequest,
        OperationContext* opCtx /* NEW ARGUMENT */
    ) {
        const auto& apiParameters = APIParameters::get(opCtx);
        return RequestType::parse(
            IDLParserErrorContext(name),
            opMsgRequest,
            apiParameters.getApiStrict().value_or(false) /* NEW */);
    }
};

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