[SERVER-25278] $geoNear aggregation stage should reject unknown arguments Created: 25/Jul/16  Updated: 23/Jun/23  Resolved: 23/Jun/23

Status: Closed
Project: Core Server
Component/s: Querying, Usability
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: David Storch Assignee: Naafiyan Ahmed (Inactive)
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Backwards Compatibility: Minor Change
Sprint: QO 2023-06-12, QO 2023-06-26
Participants:

 Description   

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",
            }
        }]
    }));
})();



 Comments   
Comment by Githook User [ 15/Jun/23 ]

Author:

{'name': 'Naafiyan Ahmed', 'email': 'naafiyan.ahmed@mongodb.com', 'username': ''}

Message: SERVER-25278 added check for unknown args and refactored if-else tower
Branch: master
https://github.com/mongodb/mongo/commit/650b6059c2d4d453dd373bfff4c167c2fe05f5b3

Generated at Thu Feb 08 04:08:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.