{"record":{"id":"0e8b70d20d580295","repo":"mongodb/mongoid","slug":"invalid-persistence-option-invalid","errorCode":null,"errorMessage":"Invalid persistence option :%{invalid}.","messagePattern":"Invalid persistence option :%(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::InvalidPersistenceOption","httpStatus":null,"severity":"error","filePath":"lib/mongoid/persistence_context.rb","lineNumber":190,"sourceCode":"    end\n\n    # The subset of provided options that may be used as storage\n    # options.\n    #\n    # @return [ Hash | nil ] the requested storage options, or nil if\n    #   none were specified.\n    #\n    # @api private\n    def requested_storage_options\n      slice = @options.slice(*Mongoid::Clients::Validators::Storage::VALID_OPTIONS)\n      slice.any? ? slice : nil\n    end\n\n    private\n\n    def set_options!(opts)\n      @options ||= opts.each.reduce({}) do |_options, (key, value)|\n        raise Errors::InvalidPersistenceOption.new(key.to_sym, VALID_OPTIONS) unless VALID_OPTIONS.include?(key.to_sym)\n\n        value ? _options.merge!(key => value) : _options\n      end\n    end\n\n    def __evaluate__(name)\n      return nil unless name\n\n      name.respond_to?(:call) ? name.call.to_sym : name.to_sym\n    end\n\n    def client_options\n      @client_options ||= begin\n        opts = options.select do |k, _v|\n          Mongo::Client::VALID_OPTIONS.include?(k.to_sym)\n        end\n        opts[:read] = { mode: opts[:read] } if opts[:read].is_a?(Symbol)\n        opts","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/persistence_context.rb#L172-L208","documentation":"Raised by the private PersistenceContext#set_options! while building a persistence context when a key in the provided options hash is not among the valid options (client, database, collection, collection_options, read, write, etc.). This generic guard rejects misspelled or unsupported persistence options such as with(store: ...) style overrides; the faulting input is the invalid option key.","triggerScenarios":"Thrown at lib/mongoid/persistence_context.rb:190 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use only valid persistence options: :client, :collection, :database, and related recognized keys","Check for typos in option names in the store_in / with options hash"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","contentChangedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}