{"record":{"id":"a7fcd641d6572d04","repo":"Automattic/mongoose","slug":"mongoose-a7fcd6","errorCode":"MONGOOSE","errorMessage":"Mongoose: the `returnOriginal` option for `mongoose.set()` is deprecated. Use `mongoose.set('returnDocument', ${replacement})` instead.","messagePattern":"Mongoose: the `returnOriginal` option for `mongoose\\.set\\(\\)` is deprecated\\. Use `mongoose\\.set\\('returnDocument', (.+?)\\)` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/mongoose.js","lineNumber":332,"sourceCode":"      } else if (!optionValue && _mongoose.transactionAsyncLocalStorage) {\n        delete _mongoose.transactionAsyncLocalStorage;\n      }\n    } else if (optionKey === 'createInitialConnection') {\n      if (optionValue && !_mongoose.connection) {\n        _createDefaultConnection(_mongoose);\n      } else if (optionValue === false && _mongoose.connection?.[defaultConnectionSymbol]) {\n        if (_mongoose.connection.readyState === STATES.disconnected && utils.hasOwnKeys(_mongoose.connection.models) === false) {\n          _mongoose.connections.shift();\n        }\n      }\n    } else if (optionKey === 'returnOriginal') {\n      if (_mongoose.options.returnDocument != null) {\n        throw new MongooseError(\n          'Cannot set `returnOriginal` when `returnDocument` is already set. Use `returnDocument` instead.'\n        );\n      }\n      const replacement = optionValue === true ? '\\'before\\'' : '\\'after\\'';\n      utils.warn(\n        'Mongoose: the `returnOriginal` option for `mongoose.set()` is deprecated. ' +\n        'Use `mongoose.set(\\'returnDocument\\', ' + replacement + ')` instead.'\n      );\n    } else if (optionKey === 'returnDocument') {\n      if (_mongoose.options.returnOriginal != null) {\n        throw new MongooseError(\n          'Cannot set `returnDocument` when `returnOriginal` is already set. Use `returnDocument` instead of `returnOriginal`.'\n        );\n      }\n    }\n  }\n\n  if (error) {\n    throw error;\n  }\n\n  return _mongoose;\n};","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/mongoose.js#L314-L350","documentation":"Error \"Mongoose: the `returnOriginal` option for `mongoose.set()` is deprecated. Use `mongoose.set('returnDocument', ${replacement})` instead.\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/mongoose.js:332 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}