mongodb/mongoid · error · Mongoid::Errors::InvalidIndex
Invalid index specification on %{klass}: %{spec}, %{options}
Error message
Invalid index specification on %{klass}: %{spec}, %{options} What it means
Error "Invalid index specification on %{klass}: %{spec}, %{options}" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/indexable/validators/options.rb:75
end
private
# Validates the options of the index spec.
#
# @api private
#
# @example Validate the options.
# Options.validate_options(Band, name: 1)
#
# @param [ Class ] klass The model class.
# @param [ Hash ] spec The index specification.
# @param [ Hash ] options The index options.
#
# @raise [ Errors::InvalidIndex ] If validation failed.
def validate_options(klass, spec, options)
options.each_pair do |name, _value|
raise Errors::InvalidIndex.new(klass, spec, options) unless VALID_OPTIONS.include?(name)
end
end
# Validates the index spec.
#
# @api private
#
# @example Validate the spec.
# Options.validate_spec(Band, name: 1)
#
# @param [ Class ] klass The model class.
# @param [ Hash ] spec The index specification.
# @param [ Hash ] options The index options.
#
# @raise [ Errors::InvalidIndex ] If validation failed.
def validate_spec(klass, spec, options)
raise Errors::InvalidIndex.new(klass, spec, options) unless spec.is_a?(::Hash)
View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/indexable/validators/options.rb:75 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/8d9b4277cb2c6541.
Report an issue: GitHub.