Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14891

Shell will create invalid dates and then persist them

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.7.3
    • Component/s: Shell
    • Minor Change
    • ALL
    • Hide

      In the shell

      > var foo
      > fred = new Date(foo)
      ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ")
      > db.boo.insert({mydate: fred})
      WriteResult({ "nInserted" : 1 })
      > db.boo.find()
      { "_id" : ObjectId("53ebe8ee637817446a874584"), "mydate" : ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ") }
      
      Show
      In the shell > var foo > fred = new Date(foo) ISODate( "0NaN-NaN-NaNTNaN:NaN:NaNZ" ) > db.boo.insert({mydate: fred}) WriteResult({ "nInserted" : 1 }) > db.boo.find() { "_id" : ObjectId( "53ebe8ee637817446a874584" ), "mydate" : ISODate( "0NaN-NaN-NaNTNaN:NaN:NaNZ" ) }

      Problem:
      Its possible for the Shell to create an invalid date, persist it and then cause other drivers to fail, python example

        File "/usr/lib/python2.6/site-packages/pymongo-2.7.1-py2.6-linux-x86_64.egg/bson/__init__.py", line 234, in _get_date
          dt = EPOCH_NAIVE + datetime.timedelta(seconds=seconds)
      InvalidBSON: normalized days too large to fit in a C int
      

      An octal dump of the .bson file from mongodump reveals

      od -xa dump/test/boo.bson 
      0000000    0026    0000    5f07    6469    5300    edeb    12d6    bc16
                & nul nul nul bel   _   i   d nul   S   k   m   V dc2 syn   <
      0000020    a63b    f008    097e    796d    6164    6574    0000    0000
                ;   &  bs   p   ~  ht   m   y   d   a   t   e nul nul nul nul
      0000040    0000    0000    0080
              nul nul nul nul nul nul
      
      

            Assignee:
            backlog-server-platform DO NOT USE - Backlog - Platform Team
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: