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

Invalid persistence option :%{invalid}.

Error message

Invalid persistence option :%{invalid}.

What it means

Error "Invalid persistence option :%{invalid}." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/persistence_context.rb:190

    end

    # The subset of provided options that may be used as storage
    # options.
    #
    # @return [ Hash | nil ] the requested storage options, or nil if
    #   none were specified.
    #
    # @api private
    def requested_storage_options
      slice = @options.slice(*Mongoid::Clients::Validators::Storage::VALID_OPTIONS)
      slice.any? ? slice : nil
    end

    private

    def set_options!(opts)
      @options ||= opts.each.reduce({}) do |_options, (key, value)|
        raise Errors::InvalidPersistenceOption.new(key.to_sym, VALID_OPTIONS) unless VALID_OPTIONS.include?(key.to_sym)

        value ? _options.merge!(key => value) : _options
      end
    end

    def __evaluate__(name)
      return nil unless name

      name.respond_to?(:call) ? name.call.to_sym : name.to_sym
    end

    def client_options
      @client_options ||= begin
        opts = options.select do |k, _v|
          Mongo::Client::VALID_OPTIONS.include?(k.to_sym)
        end
        opts[:read] = { mode: opts[:read] } if opts[:read].is_a?(Symbol)
        opts

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/persistence_context.rb:190 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/0e8b70d20d580295. Report an issue: GitHub.