{"record":{"id":"bc284e0c3f10e124","repo":"mongodb/mongoid","slug":"cannot-create-scope-scope-name-because-of-exi","errorCode":null,"errorMessage":"Cannot create scope :%{scope_name}, because of existing method %{model_name}.%{scope_name}.","messagePattern":"Cannot create scope :%(.+?), because of existing method %(.+?)\\.%(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::ScopeOverwrite","httpStatus":null,"severity":"error","filePath":"lib/mongoid/scopable.rb","lineNumber":244,"sourceCode":"        Threaded.exit_without_default_scope(self)\n      end\n\n      private\n\n      # Warns or raises exception if overriding another scope or method.\n      #\n      # @api private\n      #\n      # @example Warn or raise error if name exists.\n      #   Model.check_scope_name(\"test\")\n      #\n      # @param [ String | Symbol ] name The name of the scope.\n      #\n      # @raise [ Errors::ScopeOverwrite ] If the name exists and configured to\n      #   raise the error.\n      def check_scope_name(name)\n        return unless _declared_scopes[name] || respond_to?(name, true)\n        raise Errors::ScopeOverwrite.new(self.name, name) if Mongoid.scope_overwrite_exception\n\n        Mongoid.logger.warn(\n          \"Creating scope :#{name} which conflicts with #{self.name}.#{name}. \" +\n          \"Calls to `Mongoid::Criteria##{name}` will delegate to \" +\n          \"`Mongoid::Criteria##{name}` for criteria with klass #{self.name} \" +\n          'and will ignore the declared scope.'\n        )\n      end\n\n      # Checks if the intended scope is a valid object, either a criteria or\n      # proc with a criteria.\n      #\n      # @api private\n      #\n      # @example Check if the scope is valid.\n      #   Model.check_scope_validity({})\n      #\n      # @param [ Object ] value The intended scope.","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/scopable.rb#L226-L262","documentation":"Error \"Cannot create scope :%{scope_name}, because of existing method %{model_name}.%{scope_name}.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/scopable.rb:244 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}