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

Refactor misleading ensureNsNotCommand

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Service Arch
    • Fully Compatible
    • Service Arch 2023-10-30, Service Arch 2023-11-13

      Today the logic behind ensureNsNotCommand is a bit problematic.

      We call `serialize` on a NamespaceString object just to parse the string and check for a `$`. We should refactor that so we do not have to allocated a new `std::string` just to parse the NamespaceString data.

      The name of the method is also problematic.

       
      This documentation page shows us that there is a restriction on collection name not including a $ , and it appears that this is where we actually do that validation. Its really like the function wants to be called ensureValidQueryNamespace and its implementation should be like:
      uassert(ErrorCodes::InvalidNamespace,
      str::stream() << "Invalid collection name specified '" << nss.toStringForErrorMsg(),
      !nss.isCommand() && isValidCollection(nss.coll()) && nss != NamespaceString::kLocalOplogDollarMain));

            Assignee:
            ryan.berryhill@mongodb.com Ryan Berryhill
            Reporter:
            mathis.bessa@mongodb.com Mathis Bessa (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: