mongodb/mongoid · error

The :schema_map is configured in the :auto_encryption_option

Error message

The :schema_map is configured in the :auto_encryption_options for the client; encryption setting in Mongoid documents will be ignored.

What it means

Error "The :schema_map is configured in the :auto_encryption_options for the client; encryption setting in Mongoid documents will be ignored." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/clients/factory.rb:94

        end
      end

      # Build auto encryption options for the client based on the options
      # provided in the Mongoid client configuration and the encryption
      # schema map for the database.
      #
      # @param [ Hash ] opts Options from the Mongoid client configuration.
      # @param [ String ] database Database name to use for encryption schema map.
      #
      # @return [ Hash | nil ] Auto encryption options for the client.
      #
      # @api private
      def build_auto_encryption_options(opts, database)
        return nil unless opts[:auto_encryption_options]

        opts[:auto_encryption_options].dup.tap do |auto_encryption_options|
          if auto_encryption_options.key?(:schema_map)
            default_logger.warn(
              'The :schema_map is configured in the :auto_encryption_options for the client;' +
              ' encryption setting in Mongoid documents will be ignored.'
            )
          else
            auto_encryption_options[:schema_map] = Mongoid.config.encryption_schema_map(database)
          end
          if auto_encryption_options.key?(:key_vault_client)
            auto_encryption_options[:key_vault_client] = Mongoid.client(
              auto_encryption_options[:key_vault_client]
            )
          end
        end
      end

      MONGOID_WRAPPING_LIBRARY = {
        name: 'Mongoid',
        version: VERSION
      }.freeze

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/clients/factory.rb:94 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/5b72b9b759a9f7d4. Report an issue: GitHub.