{"record":{"id":"6f692b7a385d8f91","repo":"mongodb/mongoid","slug":"no-default-client-configuration-is-defined","errorCode":null,"errorMessage":"No default client configuration is defined.","messagePattern":"No default client configuration is defined\\.","errorType":"exception","errorClass":"Mongoid::Errors::NoDefaultClient","httpStatus":null,"severity":"error","filePath":"lib/mongoid/config/validators/client.rb","lineNumber":20,"sourceCode":"\nmodule Mongoid\n  module Config\n    module Validators\n      # Validator for client specific configuration.\n      module Client\n        extend self\n\n        # Standard configuration options.\n        STANDARD = %i[database hosts username password].freeze\n\n        # Validate the client configuration.\n        #\n        # @example Validate the client config.\n        #   Client.validate({ default: { hosts: [ \"localhost:27017\" ] }})\n        #\n        # @param [ Hash ] clients The clients config.\n        def validate(clients)\n          raise Errors::NoDefaultClient.new(clients.keys) unless clients.has_key?(:default)\n\n          clients.each_pair do |name, config|\n            validate_client_database(name, config)\n            validate_client_hosts(name, config)\n            validate_client_uri(name, config)\n          end\n        end\n\n        private\n\n        # Validate that the client config has database.\n        #\n        # @api private\n        #\n        # @example Validate the client has database.\n        #   validator.validate_client_database(:default, {})\n        #\n        # @param [ String | Symbol ] name The config key.","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/config/validators/client.rb#L2-L38","documentation":"Raised by Mongoid::Config::Validators::Client.validate when the clients configuration hash defines one or more clients but none of them is named :default. Mongoid requires a default client as the fallback for all models and operations that do not name a client explicitly; the faulting input is the clients hash lacking a default key.","triggerScenarios":"Thrown at lib/mongoid/config/validators/client.rb:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a default: entry under clients in mongoid.yml","Rename the intended primary client to :default"],"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"}