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

$geoNear aggregation stage should reject unknown arguments

    • Query Optimization
    • Minor Change
    • QO 2023-06-12, QO 2023-06-26

      The $geoNear stage currently ignores any unfamiliar arguments (see repro steps). Instead, it should check for unfamiliar arguments and fail if any are found.

      The following script demonstrates the problem:

      (function() {
          "use strict";
      
          db.c.drop();
      
          assert.commandWorked(db.c.createIndex({loc: "2dsphere"}));
          assert.writeOK(db.c.insert({loc: [0, 0]}));
      
          // This should fail due to the unknown argument, but instead it succeeds.
          assert.commandFailed(db.runCommand({
              aggregate: "c",
              pipeline: [{
                  $geoNear: {
                      near: {type: "Point", coordinates: [0, 0]},
                      distanceField: "distanceField",
                      spherical: true,
                      blah: "blaarghhh",
                  }
              }]
          }));
      })();
      

            Assignee:
            naafiyan.ahmed@mongodb.com Naafiyan Ahmed (Inactive)
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: