{"record":{"id":"72b1cdbbf321796d","repo":"Automattic/mongoose","slug":"aggregate-near-argument-has-invalid-coordinate","errorCode":null,"errorMessage":"Aggregate `near()` argument has invalid coordinates, got \"${coordinates}\"","messagePattern":"Aggregate `near\\(\\)` argument has invalid coordinates, got \"(.+?)\"","errorType":"exception","errorClass":"MongooseError","httpStatus":null,"severity":"warning","filePath":"lib/aggregate.js","lineNumber":417,"sourceCode":" * @method near\n * @memberOf Aggregate\n * @instance\n * @param {object} arg\n * @param {object|number[]} arg.near GeoJSON point or coordinates array\n * @return {Aggregate}\n * @api public\n */\n\nAggregate.prototype.near = function(arg) {\n  if (arg == null) {\n    throw new MongooseError('Aggregate `near()` must be called with non-nullish argument');\n  }\n  if (arg.near == null) {\n    throw new MongooseError('Aggregate `near()` argument must have a `near` property');\n  }\n  const coordinates = Array.isArray(arg.near) ? arg.near : arg.near.coordinates;\n  if (typeof arg.near === 'object' && (!Array.isArray(coordinates) || coordinates.length < 2 || coordinates.find(c => typeof c !== 'number'))) {\n    throw new MongooseError(`Aggregate \\`near()\\` argument has invalid coordinates, got \"${coordinates}\"`);\n  }\n\n  const op = {};\n  op.$geoNear = arg;\n  return this.append(op);\n};\n\n/*!\n * define methods\n */\n\n'group match skip limit out densify fill'.split(' ').forEach(function($operator) {\n  Aggregate.prototype[$operator] = function(arg) {\n    const op = {};\n    op['$' + $operator] = arg;\n    return this.append(op);\n  };\n});","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/aggregate.js#L399-L435","documentation":"getChanges() on a document returns the pending changes formatted for MongoDB ($set/$unset/$inc etc.), but it uses an unprefixed name that can collide with user-defined schema methods or paths. Mongoose deprecated it in favor of the $-prefixed $getChanges(), which is reserved for internal-style APIs and can never collide. The warning prints on every call; the method still works and simply delegates to $getChanges().","triggerScenarios":"Calling doc.getChanges() to inspect pending modifications before save, e.g. change-detection or audit-diff features; any helper that logs the delta produced by $__delta().","commonSituations":"Audit/diff utilities built on older Mongoose versions; code that shows users which fields changed; upgrading Mongoose and seeing the warning flood logs; frameworks that call getChanges() internally on every request.","solutions":["Replace every doc.getChanges() call with doc.$getChanges() — identical return value, no warning.","If you also mutate anything from the result, remember it is a snapshot of the change set, not a live object.","For 'did this path change?' prefer doc.isModified(path) or doc.$getChanges().$set ?? {} instead of diffing the whole object."],"exampleFix":"// before\nconst changes = doc.getChanges();\n\n// after\nconst changes = doc.$getChanges();","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on $-prefixed internals ($getChanges, $__delta) in helper code.","Codemod doc.getChanges() -> doc.$getChanges() during the next Mongoose upgrade.","Wrap change-inspection in one util (e.g. getPendingChanges(doc)) so future renames touch one file."],"tags":["mongoose","deprecation","document","change-tracking","mongoose-10"],"backgroundTag":"deprecated-api-call","analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}