[SERVER-35454] Query system does not fail cleanly for $type:0 when an index is available Created: 06/Jun/18  Updated: 29/Oct/23  Resolved: 08/Jun/18

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

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
is documented by DOCS-11803 Docs for SERVER-35454: Query system d... Closed
Related
is related to SERVER-8196 $type value should be signed extended Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

(function() {
    "use strict";
 
    db.c.drop();
    db.c.createIndex({a: 1});
    db.c.find({a: {$type: 0}}).itcount();
}());

Sprint: Query 2018-06-18
Participants:
Linked BF Score: 15

 Description   

The $type query predicate should not support type code 0, as this is used internally for the "missing" or "EOO" BSON type. The system should reject an attempt to use $type:0 with a clear error message. Instead, when an index is available for use by the $type predicate, the server returns an internal error message such as the following:

{
	"ok" : 0,
	"errmsg" : "type not supported for appendMinElementForType",
	"code" : 10061,
	"codeName" : "Location10061"
}

Users who wish to check for existence of a field should instead use $exists:false.



 Comments   
Comment by Githook User [ 08/Jun/18 ]

Author:

{'username': 'dstorch', 'name': 'David Storch', 'email': 'david.storch@10gen.com'}

Message: SERVER-35454 Make MatchExpression parser fail cleanly on $type:0.

Also, improves the error message for $type:"missing".
Branch: master
https://github.com/mongodb/mongo/commit/6de17594a59d16cb9d3e38cb360dff14b1430c6d

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