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

Unknown $type argument: #{condition}

Error message

Unknown $type argument: #{condition}

What it means

Error "Unknown $type argument: #{condition}" thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/matcher/type.rb:26

    module Type
      # Returns whether a value satisfies a $type expression.
      #
      # @param [ true | false ] exists Whether the value exists.
      # @param [ Object ] value The value to check.
      # @param [ Integer | Array<Integer> ] condition The $type condition
      #   predicate which corresponds to the BSON type enumeration.
      #
      # @return [ true | false ] Whether the value matches.
      #
      # @api private
      module_function def matches?(exists, value, condition)
        conditions = case condition
                     when Array
                       condition
                     when Integer
                       [ condition ]
                     else
                       raise Errors::InvalidQuery, "Unknown $type argument: #{condition}"
                     end
        conditions.each do |condition|
          return true if one_matches?(exists, value, condition)
        end
        false
      end

      # Returns whether a value satisfies a single $type expression
      # value.
      #
      # @param [ true | false ] exists Whether the value exists.
      # @param [ Object ] value The value to check.
      # @param [ Integer ] condition The $type condition predicate
      #   which corresponds to the BSON type enumeration.
      #
      # @return [ true | false ] Whether the value matches.
      #
      # @api private

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/matcher/type.rb:26 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/5997e2721d010988. Report an issue: GitHub.