[SERVER-61430] Raise an error when $mod remainder is not a number Created: 12/Nov/21  Updated: 20/Dec/21  Resolved: 17/Dec/21

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

Type: Bug Priority: Major - P3
Reporter: Milena Ivanova Assignee: Romans Kasperovics
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Duplicate
duplicates SERVER-23664 $mod match expression should raise an... Closed
Operating System: ALL
Sprint: QE 2021-12-13, QE 2021-12-27
Participants:

 Description   

Current implementation of $mod in v4.2 doesn't raise an error when the remainder is not a number:
db.xxx.find({a: {$mod: [2,'z']}});
{ "_id" : 2, "a" : 2, "b" : "bar" }

The problem stems from https://github.com/mongodb/mongo/blob/f6690d2a4803b3a316bf8f5ba859af35bd433b9b/src/mongo/db/matcher/expression_parser.cpp#L449

which should be

if (!r.isNumber())



 Comments   
Comment by Milena Ivanova [ 16/Dec/21 ]

I came across the bug in v4.2 when backporting another patch, it looked like the issue was fixed in the newer versions as a part of other code extension, so I was not aware that there was a special ticket for this that could be backported. ana.meza, can you help with the ticket registration?

 

Comment by Romans Kasperovics [ 16/Dec/21 ]

I guess we should still be able to "move" this ticket to backports and rename my pull request to SERVER-23664, but I am not 100% sure process-wise (this is my first ticket at MongoDB).

 milena.ivanova, sebastien.mendez : Can we do that? Are there some extra steps for backporting tickets? 

Comment by David Storch [ 15/Dec/21 ]

Didn't we already fix this in SERVER-23664? If so, shouldn't this be a backport ticket as opposed to an entirely new SERVER ticket?

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