{"record":{"id":"6927c1af515877ad","repo":"mongodb/mongoid","slug":"invalid-value-for-operator-name-argument-nega","errorCode":null,"errorMessage":"Invalid value for $#{operator_name} argument: negative integers are not allowed: #{condition}","messagePattern":"Invalid value for \\$#(.+?) argument: negative integers are not allowed: #(.+?)","errorType":"exception","errorClass":"Mongoid::Errors::InvalidQuery","httpStatus":null,"severity":"error","filePath":"lib/mongoid/matcher/bits.rb","lineNumber":30,"sourceCode":"      #   predicate as a bitmask or position list.\n      #\n      # @return [ true | false ] Whether the value matches.\n      #\n      # @api private\n      def matches?(_exists, value, condition)\n        case value\n        when BSON::Binary\n          value = value.data.split('').map { |n| '%02x' % n.ord }.join.to_i(16)\n        end\n        case condition\n        when Array\n          array_matches?(value, condition)\n        when BSON::Binary\n          int_cond = condition.data.split('').map { |n| '%02x' % n.ord }.join.to_i(16)\n          int_matches?(value, int_cond)\n        when Integer\n          if condition < 0\n            raise Errors::InvalidQuery,\n                  \"Invalid value for $#{operator_name} argument: negative integers are not allowed: #{condition}\"\n          end\n\n          int_matches?(value, condition)\n        when Float\n          # Allow floats that are whole numbers (e.g. 50.0), but reject those\n          # with a fractional part (e.g. 50.1) since bitwise ops require integers.\n          int_cond = condition.to_i\n          if int_cond == condition\n            if int_cond < 0\n              raise Errors::InvalidQuery,\n                    \"Invalid value for $#{operator_name} argument: negative numbers are not allowed: #{condition}\"\n            end\n\n            int_matches?(value, int_cond)\n          else\n            raise Errors::InvalidQuery,\n                  \"Invalid type for $#{operator_name} argument: not representable as an integer: #{condition}\"","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/matcher/bits.rb#L12-L48","documentation":"Error \"Invalid value for $#{operator_name} argument: negative integers are not allowed: #{condition}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/matcher/bits.rb:30 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"}