{"record":{"id":"f6356329fd0e3b7b","repo":"redis/redis-rb","slug":"by-must-be-an-integer-byint-or-a-float-byfloat","errorCode":null,"errorMessage":"by must be an Integer (BYINT) or a Float (BYFLOAT), got #{by.class}","messagePattern":"by must be an Integer \\(BYINT\\) or a Float \\(BYFLOAT\\), got #(.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/strings.rb","lineNumber":130,"sourceCode":"      #   `ex`/`px`/`exat`/`pxat`\n      # @return [Array(Integer, Integer), Array(Float, Float)]\n      #   `[new_value, applied_increment]` — Integers in integer mode, Floats\n      #   in float mode (under RESP2 and RESP3 alike); `applied_increment`\n      #   is 0 when the operation was skipped as out of bounds\n      def increx(key, by: nil, lbound: nil, ubound: nil, saturate: nil,\n                 ex: nil, px: nil, exat: nil, pxat: nil, persist: nil, enx: nil)\n        if [ex, px, exat, pxat, persist].count { |option| option } > 1\n          raise ArgumentError, \"ex, px, exat, pxat and persist are mutually exclusive\"\n        end\n        raise ArgumentError, \"enx is incompatible with persist\" if enx && persist\n        raise ArgumentError, \"enx requires one of ex, px, exat or pxat\" if enx && !(ex || px || exat || pxat)\n\n        # The Ruby type of `by` selects the wire mode; anything else would\n        # have to silently pick a mode, so it is rejected instead.\n        float_mode = case by\n        when nil, Integer then false\n        when Float then true\n        else raise TypeError, \"by must be an Integer (BYINT) or a Float (BYFLOAT), got #{by.class}\"\n        end\n\n        args = [:increx, key]\n        args << (float_mode ? \"BYFLOAT\" : \"BYINT\") << by if by\n        args << \"LBOUND\" << increx_bound(:lbound, lbound, float_mode) if lbound\n        args << \"UBOUND\" << increx_bound(:ubound, ubound, float_mode) if ubound\n        args << \"SATURATE\" if saturate\n        args << \"EX\" << Integer(ex) if ex\n        args << \"PX\" << Integer(px) if px\n        args << \"EXAT\" << Integer(exat) if exat\n        args << \"PXAT\" << Integer(pxat) if pxat\n        args << \"PERSIST\" if persist\n        args << \"ENX\" if enx\n\n        if float_mode\n          # RESP2 replies with bulk strings, RESP3 with native doubles;\n          # converge both on Float.\n          send_command(args) { |reply| reply.is_a?(Array) ? reply.map(&Floatify) : reply }","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/strings.rb#L112-L148","documentation":"Error \"by must be an Integer (BYINT) or a Float (BYFLOAT), got #{by.class}\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/commands/strings.rb:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass by: as an Integer for BYINT or a Float for BYFLOAT, e.g. by: 2 or by: 0.5.","Coerce the value with to_i or to_f before calling if it arrives as a string."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}