mongodb/mongoid · error · Mongoid::Errors::InvalidQuery

$all argument must be an array: #{Errors::InvalidQuery.trunc

Error message

$all argument must be an array: #{Errors::InvalidQuery.truncate_expr(condition)}

What it means

Error "$all argument must be an array: #{Errors::InvalidQuery.truncate_expr(condition)}" thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/matcher/all.rb:20

  module Matcher
    # In-memory matcher for $all expression.
    #
    # @see https://www.mongodb.com/docs/manual/reference/operator/query/all/
    #
    # @api private
    module All
      # Returns whether a value satisfies an $all expression.
      #
      # @param [ true | false ] exists Not used.
      # @param [ Object ] value The value to check.
      # @param [ Array<Object> ] condition The $all condition predicate.
      #
      # @return [ true | false ] Whether the value matches.
      #
      # @api private
      module_function def matches?(_exists, value, condition)
        unless condition.is_a?(Array)
          raise Errors::InvalidQuery, "$all argument must be an array: #{Errors::InvalidQuery.truncate_expr(condition)}"
        end

        !condition.empty? && condition.all? do |c|
          case c
          when ::Regexp, BSON::Regexp::Raw
            Regex.matches_array_or_scalar?(value, c)
          else
            EqImpl.matches?(true, value, c, '$all')
          end
        end
      end
    end
  end
end

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/matcher/all.rb:20 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23). Data as JSON: /api/errors/fa0cc0e60de2b936. Report an issue: GitHub.