Automattic/mongoose · error · MongooseError
Cannot set `hydratedPopulatedDocs` option to false if `virtu
Error message
Cannot set `hydratedPopulatedDocs` option to false if `virtuals` option is truthy because `virtuals: true` also sets populated virtuals
What it means
Error "Cannot set `hydratedPopulatedDocs` option to false if `virtuals` option is truthy because `virtuals: true` also sets populated virtuals" thrown in Automattic/mongoose.
Source
Thrown at lib/model.js:4022
* // hydrate previous data into a Mongoose document
* const mongooseCandy = Candy.hydrate({ _id: '54108337212ffb6d459f854c', type: 'jelly bean' });
*
* @param {object} obj
* @param {object|string|string[]} [projection] optional projection containing which fields should be selected for this document
* @param {object} [options] optional options
* @param {boolean} [options.setters=false] if true, apply schema setters when hydrating
* @param {boolean} [options.hydratedPopulatedDocs=false] if true, populates the docs if passing pre-populated data
* @param {boolean} [options.virtuals=false] if true, sets any virtuals present on `obj`
* @param {boolean|'throw'} [options.strict=false] configure strict mode for the hydrated document. In particular, if strict is false, fields not in the schema won't be stripped out; if strict is 'throw', `hydrate()` will throw an error if there are any fields that are not in the schema. Defaults to true (silently strip out fields not in the schema).
* @return {Document} document instance
* @api public
*/
Model.hydrate = function hydrate(obj, projection, options) {
_checkContext(this, 'hydrate');
if (options?.virtuals && options?.hydratedPopulatedDocs === false) {
throw new MongooseError('Cannot set `hydratedPopulatedDocs` option to false if `virtuals` option is truthy because `virtuals: true` also sets populated virtuals');
}
if (projection != null) {
if (obj?.$__ != null) {
obj = obj.toObject(internalToObjectOptions);
}
projection = parseProjection(projection);
obj = applyProjection(obj, projection);
}
const document = require('./queryHelpers').createModel(this, obj, projection, projection, options);
document.$init(obj, options);
return document;
};
/**
* Same as `updateOne()`, except MongoDB will update _all_ documents that match
* `filter` (as opposed to just the first one) regardless of the value of
* the `multi` option.View on GitHub (pinned to 49cdab0136)
When it happens
Trigger: Thrown at lib/model.js:4022 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Automattic/mongoose@49cdab0136 (2026-08-21).
Data as JSON: /api/errors/ff044195590366f3.
Report an issue: GitHub.