[SERVER-23703] NumberDecimal accepts any random string Created: 13/Apr/16  Updated: 06/Jun/16  Resolved: 27/May/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.3.4
Fix Version/s: 3.3.8

Type: Bug Priority: Major - P3
Reporter: Bernie Hackett Assignee: Vincent Do
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Integrate+Tuning 15 (06/03/16)
Participants:

 Description   

It seems like you can pass any string random string that doesn't match an IEEE 754 decimal to NumberDecimal and the shell will happily encode it as "NaN". Should it error if the value makes no sense?

MongoDB Enterprise repl0:PRIMARY> db.test.count()
0
MongoDB Enterprise repl0:PRIMARY> db.test.insert({d: NumberDecimal("this is total garbage")})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise repl0:PRIMARY> db.test.count()
1
MongoDB Enterprise repl0:PRIMARY> db.test.findOne()
{ "_id" : ObjectId("570ed43b02e7d49d28d860aa"), "d" : NumberDecimal("NaN") }



 Comments   
Comment by Githook User [ 27/May/16 ]

Author:

{u'username': u'vincentdo', u'name': u'Vincent Do', u'email': u'do.vincent@live.com'}

Message: SERVER-23703 Make NumberDecimal accepts only valid strings
Branch: master
https://github.com/mongodb/mongo/commit/ba23c68f0bf0a594a4af7080900ea03bda133fa4

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