Automattic/mongoose · error · MongooseError

Empty or invalid filter not allowed with requireFilter enabl

Error message

Empty or invalid filter not allowed with requireFilter enabled

What it means

Error "Empty or invalid filter not allowed with requireFilter enabled" thrown in Automattic/mongoose.

Source

Thrown at lib/query.js:193

  if (utils.hasOwnKeys(obj) === false) return true;

  // Check $and, $or, $nor arrays
  for (const key of ['$and', '$or', '$nor']) {
    if (Array.isArray(obj[key])) {
      // If array is empty or all elements are empty objects, consider it empty
      if (obj[key].length === 0 || obj[key].every(item => isEmptyFilter(item))) {
        return true;
      }
    }
  }

  return false;
}

// Helper function to check for empty/invalid filter
function checkRequireFilter(filter, options) {
  if (options?.requireFilter && isEmptyFilter(filter)) {
    throw new MongooseError('Empty or invalid filter not allowed with requireFilter enabled');
  }
}

/*!
 * inherit mquery
 */

Query.prototype = new mquery();
Query.prototype.constructor = Query;

Object.defineProperty(Query.prototype, '_update', {
  configurable: true,
  enumerable: true,
  get: function() {
    _cloneUpdateIfShared(this);
    return this[queryUpdateSymbol];
  },
  set: function(v) {

View on GitHub (pinned to 49cdab0136)

When it happens

Trigger: Thrown at lib/query.js:193 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/9411fe17faefae05. Report an issue: GitHub.