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