{"record":{"id":"dcdac6d0432ea2ab","repo":"mongodb/mongoid","slug":"kms-provider-name-must-be-provided-when-there-are","errorCode":null,"errorMessage":"kms_provider_name must be provided when there are multiple kms providers","messagePattern":"kms_provider_name must be provided when there are multiple kms providers","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/tasks/encryption.rb","lineNumber":98,"sourceCode":"      #\n      # If kms_provider_name is provided, it will be used. Otherwise, if there\n      # is only one kms provider, that provider will be used. Otherwise, an\n      # error will be raised.\n      #\n      # @param [ String | nil ] kms_provider_name The name of the kms provider\n      #   as provided by the user.\n      # @param [ Hash ] kms_providers The kms providers hash from the client's\n      #   auto_encryption_options.\n      #\n      # @return [ String ] The kms provider name to use for creating a data\n      #   key.\n      def get_kms_provider_name(kms_provider_name, kms_providers)\n        if kms_provider_name\n          kms_provider_name\n        elsif kms_providers.keys.length == 1\n          kms_providers.keys.first\n        else\n          raise ArgumentError, 'kms_provider_name must be provided when there are multiple kms providers'\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":80,"sourceCodeEnd":104,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/tasks/encryption.rb#L80-L104","documentation":"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.","triggerScenarios":"Thrown at lib/mongoid/tasks/encryption.rb:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}