Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-758

Better type validation for config(<param>,<value>)

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.13.2
    • Affects Version/s: 0.12.1
    • Component/s: CLI Module
    • None
    • Not Needed
    • Hide

      None

      Show
      None
    • Iteration Chicago

      Problem Description

      config.set("inspectDepth", VALUE) should accept positive integers and javascript Infinity. However, it also accepts other values.  

      Steps to Reproduce

      See below for examples and expected results. 

      Expected Results

      Only positive integers and Infinity accepted

      Actual Results

      0, negative integers, random strings, arrays, are accepted

      Additional Notes

      // 0 integer values (maybe this has a useful meaning?)

      Enterprise rs0 [direct: primary]> config.set("inspectDepth", 0)

      Setting "inspectDepth" has been changed

      Enterprise rs0 [direct: primary]> db.depth.find({})

      [ [Object] ]

       

      // Negative value (maybe this has a useful meaning?)

      Enterprise rs0 [direct: primary]> config.set("inspectDepth", -3)

      Setting "inspectDepth" has been changed

      Enterprise rs0 [direct: primary]> db.depth.find({})

      [Array]

       

      // string

      Enterprise rs0 [direct: primary]> config.set("inspectDepth", "AAA")

      Setting "inspectDepth" has been changed

      Enterprise rs0 [direct: primary]> db.depth.find({})

      [

        {

          _id: ObjectId("60956cac51d4986dc3189e57"),

          a: {

            b: {

              c: { d: { e:

      { f: 1 }

      } }

            }

          }

        }

      ]

       

      // Int as string

      Enterprise rs0 [direct: primary]> config.set("inspectDepth", "2")

      Setting "inspectDepth" has been changed

      Enterprise rs0 [direct: primary]> db.depth.find({})

      [ { _id: ObjectId("60956cac51d4986dc3189e57"), a:

      { b: [Object] }

      } ]

       

      // array (also char arrays)

      Enterprise rs0 [direct: primary]> config.set("inspectDepth", [1, 5])

      Setting "inspectDepth" has been changed

      Enterprise rs0 [direct: primary]> db.depth.find({})

      [

        {

          _id: ObjectId("60956cac51d4986dc3189e57"),

          a: {

            b: {

              c: { d: { e:

      { f: 1 }

      } }

            }

          }

        }

      ]

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            dave.cuthbert@mongodb.com Dave Cuthbert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: