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

Mongos count command should report errors in errmsg field, not cause field

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.5
    • Affects Version/s: 3.4.2
    • Component/s: Querying, Sharding
    • None
    • Fully Compatible
    • Query 2017-03-27

      Specifying a query hint that points to a non-existent index produces a rather generic error message:

      Fatal error: Uncaught exception 'MongoDB\Driver\Exception\ConnectionException' with message 'failed on : shard0000' in app/vendor/composer/mongodb/mongodb/src/Operation/Count.php:111
      Stack trace:
      #0 app/vendor/composer/mongodb/mongodb/src/Operation/Count.php(111): MongoDB\Driver\Server->executeCommand('keywords', Object(MongoDB\Driver\Command), Object(MongoDB\Driver\ReadPreference))
      #1 app/vendor/composer/mongodb/mongodb/src/Collection.php(233): MongoDB\Operation\Count->execute(Object(MongoDB\Driver\Server))
      #2 app/scratch08.php(20): MongoDB\Collection->count(Array, Array)
      #3 {main}
        thrown in app/vendor/composer/mongodb/mongodb/src/Operation/Count.php on line 111

      It would be awesome if the error message hinted at what went wrong.

      Reproduce case:

      $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
      
      $col = new \MongoDB\Collection($manager, 'keywords', 'keywords');
      
      $res = $col->count(
          [
              '_id' => [
                  '$in' => []
              ]
          ],
          [
              'hint' => [
                  '_not_exists' => 1
              ]
          ]
      );

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            igorwrg Igor Wiedler
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: