{"record":{"id":"98538849afa5e55a","repo":"mongodb/mongoid","slug":"or-argument-must-be-an-array-errors-invalidqu","errorCode":null,"errorMessage":"$or argument must be an array: #{Errors::InvalidQuery.truncate_expr(expr)}","messagePattern":"\\$or argument must be an array: #(.+?)","errorType":"exception","errorClass":"Mongoid::Errors::InvalidQuery","httpStatus":null,"severity":"error","filePath":"lib/mongoid/matcher/or.rb","lineNumber":19,"sourceCode":"module Mongoid\n  module Matcher\n    # In-memory matcher for $or expression.\n    #\n    # @see https://www.mongodb.com/docs/manual/reference/operator/query/or/\n    #\n    # @api private\n    module Or\n      # Returns whether a document satisfies an $or expression.\n      #\n      # @param [ Mongoid::Document ] document The document.\n      # @param [ Array<Hash> ] expr The $or 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, \"$or argument must be an array: #{Errors::InvalidQuery.truncate_expr(expr)}\"\n        end\n\n        if expr.empty?\n          raise Errors::InvalidQuery, \"$or argument must be a non-empty array: #{Errors::InvalidQuery.truncate_expr(expr)}\"\n        end\n\n        expr.any? do |sub_expr|\n          Expression.matches?(document, sub_expr)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/matcher/or.rb#L1-L33","documentation":"Error \"$or argument must be an array: #{Errors::InvalidQuery.truncate_expr(expr)}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/matcher/or.rb:19 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"}