[SERVER-85909] Investigate why listCollections validates views that should not be returned when the filter is an $and Created: 30/Jan/24  Updated: 31/Jan/24  Resolved: 30/Jan/24

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

Type: Task Priority: Major - P3
Reporter: Cheahuychou Mao Assignee: Backlog - Query Execution
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Description   

According to the comment in list_collections_no_view.js which got added in SERVER-25942, when listCollections doesn't need to return a view, it should validate it. But it looks like it if we change the filter from this

{
               "$or": [
                     {    
                           "type": "collection"
                      }, 
                      {
                            "type": {
                                    $exists: false
                              }
                       }
                ]
}

to this,

{
		"$and" : [
			{
				"name" : {
					"$ne" : "system.profile"
				}
			},
			{
				"$or" : [
					{
						"type" : "collection"
					},
					{
						"type" : {
							"$exists" : false
						}
					}
				]
			}
		]
	}
}

the listCollection command would fail with the error below:

{
	"ok" : 0,
	"errmsg" : "Invalid view definition detected in the view catalog. Remove the invalid view manually to prevent disallowing any further usage of the view catalog.",
	"code" : 182,
	"codeName" : "InvalidViewDefinition"
}


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