mongodb/mongoid · error · Mongoid::Errors::InvalidQuery
$gte argument cannot be a Range: #
Error message
$gte argument cannot be a Range: #{Errors::InvalidQuery.truncate_expr(condition)} What it means
Raised by Mongoid::Matcher::Gte.matches? when the $gte condition is a Range. Ranges cannot be meaningfully compared with >= as a single predicate in memory, so they are rejected as the $gte condition; the faulting input is the Range condition.
Solutions
- Pass a scalar value (e.g. the range's first element) to $gte
- Express range containment with $gte/$lt combination on scalar bounds
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at lib/mongoid/matcher/gte.rb:21 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/1f4b06ebe4adda77.
Report an issue: GitHub.
Appendix: source
Thrown at lib/mongoid/matcher/gte.rb:21
# In-memory matcher for $gte expression.
#
# @see https://www.mongodb.com/docs/manual/reference/operator/query/gte/
#
# @api private
module Gte
# Returns whether a value satisfies a $gte expression.
#
# @param [ true | false ] exists Whether the value exists.
# @param [ Object ] value The value to check.
# @param [ Object ] condition The $gte condition predicate.
#
# @return [ true | false ] Whether the value matches.
#
# @api private
module_function def matches?(exists, value, condition)
case condition
when Range
raise Errors::InvalidQuery, "$gte argument cannot be a Range: #{Errors::InvalidQuery.truncate_expr(condition)}"
end
FieldOperator.apply_array_field_operator(exists, value, condition) do |v|
FieldOperator.apply_comparison_operator(:>=, v, condition)
end
end
end
end
end
View on GitHub (pinned to 0da0e23d71)