{"record":{"id":"e7087efe4039cf0f","repo":"mongodb/mongoid","slug":"ne-operator-does-not-allow-regexp-arguments","errorCode":null,"errorMessage":"'$ne' operator does not allow Regexp arguments: #{Errors::InvalidQuery.truncate_expr(condition)}","messagePattern":"'\\$ne' operator does not allow Regexp arguments: #(.+?)","errorType":"exception","errorClass":"Mongoid::Errors::InvalidQuery","httpStatus":null,"severity":"error","filePath":"lib/mongoid/matcher/ne.rb","lineNumber":21,"sourceCode":"    # In-memory matcher for $ne expression.\n    #\n    # @see https://www.mongodb.com/docs/manual/reference/operator/query/ne/\n    #\n    # @api private\n    module Ne\n      # Returns whether a value satisfies an $ne expression.\n      #\n      # @param [ true | false ] exists Whether the value exists.\n      # @param [ Object ] value The value to check.\n      # @param [ Object ] condition The $ne condition predicate.\n      #\n      # @return [ true | false ] Whether the value matches.\n      #\n      # @api private\n      module_function def matches?(exists, value, condition)\n        case condition\n        when ::Regexp, BSON::Regexp::Raw\n          raise Errors::InvalidQuery, \"'$ne' operator does not allow Regexp arguments: #{Errors::InvalidQuery.truncate_expr(condition)}\"\n        end\n\n        !EqImpl.matches?(exists, value, condition, '$ne')\n      end\n    end\n  end\nend\n","sourceCodeStart":3,"sourceCodeEnd":29,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/matcher/ne.rb#L3-L29","documentation":"Error \"'$ne' operator does not allow Regexp arguments: #{Errors::InvalidQuery.truncate_expr(condition)}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/matcher/ne.rb:21 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"}