mongodb/mongoid · error · ArgumentError
kms_provider_name must be provided when there are multiple…
Error message
kms_provider_name must be provided when there are multiple kms providers
What it means
Raised by Mongoid::Tasks::Encryption#get_kms_provider_name when no kms_provider_name argument is supplied and the client's auto_encryption_options configure more than one KMS provider, making the choice ambiguous. The faulting input is the omitted provider name in a multi-provider configuration.
Solutions
- Pass the provider name to the task, e.g. kms_provider_name: 'aws'
- Configure only one KMS provider if a default choice is desired
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/mongoid/tasks/encryption.rb:98 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/dcdac6d0432ea2ab.
Report an issue: GitHub.
Appendix: source
Thrown at lib/mongoid/tasks/encryption.rb:98
#
# If kms_provider_name is provided, it will be used. Otherwise, if there
# is only one kms provider, that provider will be used. Otherwise, an
# error will be raised.
#
# @param [ String | nil ] kms_provider_name The name of the kms provider
# as provided by the user.
# @param [ Hash ] kms_providers The kms providers hash from the client's
# auto_encryption_options.
#
# @return [ String ] The kms provider name to use for creating a data
# key.
def get_kms_provider_name(kms_provider_name, kms_providers)
if kms_provider_name
kms_provider_name
elsif kms_providers.keys.length == 1
kms_providers.keys.first
else
raise ArgumentError, 'kms_provider_name must be provided when there are multiple kms providers'
end
end
end
end
end
View on GitHub (pinned to 0da0e23d71)