[SERVER-65029] Consider making the profile command error when given unrecognized options Created: 29/Mar/22  Updated: 29/Oct/23  Resolved: 09/May/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: Max Hirschhorn Assignee: Zixuan Zhuang
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
Backwards Compatibility: Minor Change
Sprint: QE 2022-04-18, QE 2022-05-02, QE 2022-05-16
Participants:
Linked BF Score: 72

 Description   

The profile command is user-facing but specifies {strict: false} for how it parses its input. This means if the operator misspells an argument to the commands or includes a non-existing one, they won't always get an error. Changing the command to be {strict: true} would protect against this but should be weighed against driver's and/or server's ability to send the command internally without needing to know which version of the server they are talking with.


import pathlib
import yaml
 
def check_file(pathname):
    with open(pathname) as data:
        blob = yaml.safe_load(data)
    for (command, command_details) in blob.get("commands", {}).items():
        if not command_details.get("strict", True):
            yield command_details["command_name"]
 
for pathname in pathlib.Path().rglob("src/mongo/**/*.idl"):
    if str(pathname) == "src/mongo/idl/unittest.idl":
        continue
    for command in check_file(pathname):
        if not command.startswith("_"):
            print(f"{command} in {pathname}")



 Comments   
Comment by Githook User [ 06/May/22 ]

Author:

{'name': 'Zixuan Zhuang', 'email': 'zixuan.zhuang@mongodb.com', 'username': 'leozzx'}

Message: SERVER-65029 Make profile command strict to true
Branch: master
https://github.com/mongodb/mongo/commit/d3b24d42db3c1fc59b7ef3aee97994997aff6ad9

Comment by Kyle Suarez [ 04/Apr/22 ]

The Drivers have confirmed that this change would not negatively affect any of them, so I'd vote to go ahead and schedule this. (neweng?)

Generated at Thu Feb 08 06:01:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.