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

Consider making the profile command error when given unrecognized options

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Minor Change
    • QE 2022-04-18, QE 2022-05-02, QE 2022-05-16
    • 72

      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}")
      

            Assignee:
            zixuan.zhuang@mongodb.com Zixuan Zhuang
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: