{"record":{"id":"ca4730bb13cbe7af","repo":"mongodb/mongoid","slug":"the-class-klass-is-not-registered-with-the-reso","errorCode":null,"errorMessage":"The class %{klass} is not registered with the resolver %{resolver}.","messagePattern":"The class %(.+?) is not registered with the resolver %(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::UnregisteredClass","httpStatus":null,"severity":"error","filePath":"lib/mongoid/model_resolver.rb","lineNumber":136,"sourceCode":"\n      # Returns the list of all keys for the given record's class, in priority order (with highest\n      # priority keys first).\n      #\n      # @param [ Mongoid::Document] record the record instance for which to query the registered keys.\n      #\n      # @raise Mongoid::Errors::UnregisteredClass if the record's class has not been registered with this resolver.\n      #\n      # @return [ Array<String> ] the list of keys that have been registered for the given class.\n      def keys_for(record)\n        @model_to_keys.fetch(record.class) do |klass|\n          # figure out which resolver this is\n          resolver = if self == Mongoid::ModelResolver.instance\n                       :default\n                     else\n                       Mongoid::ModelResolver.resolvers.keys.detect { |k| Mongoid::ModelResolver.resolvers[k] == self }\n                     end\n          resolver ||= self # if it hasn't been registered, we'll show it the best we can\n          raise Mongoid::Errors::UnregisteredClass.new(klass, resolver)\n        end\n      end\n\n      # Returns the document class that has been registered by the given key.\n      #\n      # @param [ String ] key the key by which to query the corresponding class.\n      #\n      # @raise Mongoid::Errors::UnrecognizedModelAlias if the given key has not\n      #   been registered with this resolver.\n      #\n      # @return [ Class ] the document class that has been registered with the given key.\n      def model_for(key)\n        @key_to_model.fetch(key) do\n          raise Mongoid::Errors::UnrecognizedModelAlias, key\n        end\n      end\n    end\n  end","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/model_resolver.rb#L118-L154","documentation":"Raised by Mongoid::ModelResolver#keys_for when the class of the given record was never registered with this resolver via register_model (or register). The resolver maps model classes to alias keys and raises Mongoid::Errors::UnregisteredClass when asked for keys of an unknown class.","triggerScenarios":"Thrown at lib/mongoid/model_resolver.rb:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the model class with the resolver (e.g. via include/resolver registration API) before querying keys","Verify the correct resolver is being used for this model"],"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"}