{"record":{"id":"8133129f27c2d948","repo":"mongodb/mongoid","slug":"and-argument-must-be-a-non-empty-array-errors","errorCode":null,"errorMessage":"$and argument must be a non-empty array: #{Errors::InvalidQuery.truncate_expr(expr)}","messagePattern":"\\$and argument must be a non-empty array: #(.+?)","errorType":"exception","errorClass":"Mongoid::Errors::InvalidQuery","httpStatus":null,"severity":"error","filePath":"lib/mongoid/matcher/and.rb","lineNumber":23,"sourceCode":"    # @see https://www.mongodb.com/docs/manual/reference/operator/query/and/\n    #\n    # @api private\n    module And\n      # Returns whether a document satisfies an $and expression.\n      #\n      # @param [ Mongoid::Document ] document The document.\n      # @param [ Array<Hash> ] expr The $and conditions.\n      #\n      # @return [ true | false ] Whether the document matches.\n      #\n      # @api private\n      module_function def matches?(document, expr)\n        unless expr.is_a?(Array)\n          raise Errors::InvalidQuery, \"$and argument must be an array: #{Errors::InvalidQuery.truncate_expr(expr)}\"\n        end\n\n        if expr.empty?\n          raise Errors::InvalidQuery, \"$and argument must be a non-empty array: #{Errors::InvalidQuery.truncate_expr(expr)}\"\n        end\n\n        expr.all? do |sub_expr|\n          Expression.matches?(document, sub_expr)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":5,"sourceCodeEnd":33,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/matcher/and.rb#L5-L33","documentation":"Error \"$and argument must be a non-empty array: #{Errors::InvalidQuery.truncate_expr(expr)}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/matcher/and.rb:23 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":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}