Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-493

dump/export --query panics on invalid Date in query

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0-rc5
    • Affects Version/s: None
    • Component/s: None
    • None
    • 2014 Last MCI Iteration, 2015-01 Iteration

      mongo-tools/test/qa-tests/mongoexport --out query_export.json --db test --collection source --query {x:{$gt:Date("2014-12-11T13:50:39.498Z"), $lt:Date("2014-12-11T13:58:39.498Z")}} --host 127.0.0.1:31000

      sh43455| panic: interface conversion: interface is string, not json.Number [recovered]
      sh43455| 	panic: interface conversion: interface is string, not json.Number
      sh43455|
      sh43455| goroutine 16 [running]:
      sh43455| runtime.panic(0x24cec0, 0xc20803a140)
      sh43455| 	/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
      sh43455| github.com/mongodb/mongo-tools/common/json.funcĀ·003()
      sh43455| 	/data/mci/shell/src/src/mongo-tools-repo/.gopath/src/github.com/mongodb/mongo-tools/common/json/decode.go:200 +0x84
      sh43455| runtime.panic(0x24cec0, 0xc20803a140)
      sh43455| 	/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
      sh43455| github.com/mongodb/mongo-tools/common/json.(*decodeState).getDate(0xc208024000, 0x0, 0x0)
      sh43455| 	/data/mci/shell/src/src/mongo-tools-repo/.gopath/src/github.com/mongodb/mongo-tools/common/json/date.go:63 +0x19b
      sh43455| github.com/mongodb/mongo-tools/common/json.(*decodeState).getExtendedLiteral(0xc208024000, 0xc2080800f8, 0x4, 0x48, 0x0, 0x0, 0xc208022a50)
      sh43455| 	/data/mci/shell/src/src/mongo-tools-repo/.gopath/src/github.com/mongodb/mongo-tools/common/json/mongo_extjson.go:263 +0x2b5
      

      It should at least complain with a more friendly error, like the legacy tool:

      assertion: 16619 code FailedToParse: FailedToParse: Date expecting integer milliseconds: offset:13 of:{x:{$gt:Date("2014-12-11T13:50:39.498Z"), $lt:Date("2014-12-11T13:58:39.498Z")}}
      

      Or better yet, we could just parse the date string and if its valid, allow the query as-is.

            Assignee:
            shraya.ramani Shraya Ramani
            Reporter:
            mikeo@mongodb.com Michael O'Brien
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: