[SERVER-39231] Create command should reject incorrect types for known options Created: 28/Jan/19  Updated: 29/Oct/23  Resolved: 03/Apr/19

Status: Closed
Project: Core Server
Component/s: Querying, Usability
Affects Version/s: None
Fix Version/s: 4.1.10

Type: Improvement Priority: Major - P3
Reporter: Shane Harvey Assignee: Gregory Wlodarek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-40345 Remove the 'temp' field from the 'cre... Closed
Related
related to SERVER-25459 Create command should reject unknown ... Closed
is related to PYTHON-1728 What is the proper way to create a ca... Closed
Backwards Compatibility: Fully Compatible
Sprint: Storage NYC 2019-03-25, Storage NYC 2019-04-08
Participants:

 Description   

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).



 Comments   
Comment by Githook User [ 03/Apr/19 ]

Author:

{'name': 'Gregory Wlodarek', 'username': 'GWlodarek', 'email': 'gregory.wlodarek@mongodb.com'}

Message: SERVER-39231 'create' command should reject incorrect types for known options
Branch: master
https://github.com/mongodb/mongo/commit/24aa7dc8f39e133da8a3e405863e5dbbd980f68d

Comment by Githook User [ 03/Apr/19 ]

Author:

{'name': 'Gregory Wlodarek', 'username': 'GWlodarek', 'email': 'gregory.wlodarek@mongodb.com'}

Message: SERVER-39231 Remove $nExtents from tests
Branch: master
https://github.com/mongodb/mongo/commit/573495bbf17851758e7fcf76c85a3d66d6b53342

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