{"record":{"id":"9411fe17faefae05","repo":"Automattic/mongoose","slug":"empty-or-invalid-filter-not-allowed-with-requirefi","errorCode":null,"errorMessage":"Empty or invalid filter not allowed with requireFilter enabled","messagePattern":"Empty or invalid filter not allowed with requireFilter enabled","errorType":"exception","errorClass":"MongooseError","httpStatus":null,"severity":"error","filePath":"lib/query.js","lineNumber":193,"sourceCode":"  if (utils.hasOwnKeys(obj) === false) return true;\n\n  // Check $and, $or, $nor arrays\n  for (const key of ['$and', '$or', '$nor']) {\n    if (Array.isArray(obj[key])) {\n      // If array is empty or all elements are empty objects, consider it empty\n      if (obj[key].length === 0 || obj[key].every(item => isEmptyFilter(item))) {\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\n\n// Helper function to check for empty/invalid filter\nfunction checkRequireFilter(filter, options) {\n  if (options?.requireFilter && isEmptyFilter(filter)) {\n    throw new MongooseError('Empty or invalid filter not allowed with requireFilter enabled');\n  }\n}\n\n/*!\n * inherit mquery\n */\n\nQuery.prototype = new mquery();\nQuery.prototype.constructor = Query;\n\nObject.defineProperty(Query.prototype, '_update', {\n  configurable: true,\n  enumerable: true,\n  get: function() {\n    _cloneUpdateIfShared(this);\n    return this[queryUpdateSymbol];\n  },\n  set: function(v) {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/query.js#L175-L211","documentation":"Error \"Empty or invalid filter not allowed with requireFilter enabled\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/query.js:193 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"}