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

Create command should reject incorrect types for known options

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.10
    • Affects Version/s: None
    • Component/s: Querying, Usability
    • None
    • Fully Compatible
    • Storage NYC 2019-03-25, Storage NYC 2019-04-08

      Create command should reject incorrect types for known options. It's easy to accidentally provide the wrong types for a "create" option, like providing a string for "max":

      MongoDB Enterprise > db.createCollection("test", {capped:true, size:10, max:"10"})
      { "ok" : 1 }
      MongoDB Enterprise > db.getCollectionInfos()
      [
      	{
      		"name" : "test",
      		"type" : "collection",
      		"options" : {
      			"capped" : true,
      			"size" : 256
      		},
      ...
      

      Or forgetting the "capped" option but including "size" and "max":

      MongoDB Enterprise > db.createCollection("test2", {size:10, max:10})
      { "ok" : 1 }
      MongoDB Enterprise > db.getCollectionInfos()
      [
      	{
      		"name" : "test2",
      		"type" : "collection",
      		"options" : {
      
      		},
      ...
      

      In both of these cases, the server silently ignores some of the options and creates a collection that, almost certainly, is not what the user wanted. I think it would be an improvement for the "create" command to return an InvalidOptions error instead.

      This is semi-related to SERVER-25459 (Create command should reject unknown options) and SERVER-16069 (Input validation on the arguments to createCollection).

            Assignee:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: