redis/redis-rb · error · ArgumentError

timeout must be an Integer or Float, got: #{timeout.class}

Error message

timeout must be an Integer or Float, got: #{timeout.class}

What it means

Error "timeout must be an Integer or Float, got: #{timeout.class}" thrown in redis/redis-rb.

Source

Thrown at lib/redis/commands/lists.rb:392

      # @param [String] key
      # @param [Integer] start start index
      # @param [Integer] stop stop index
      # @return [String] `OK`
      def ltrim(key, start, stop)
        send_command([:ltrim, key, Integer(start), Integer(stop)])
      end

      private

      def _bpop(cmd, args, &blk)
        timeout = if args.last.is_a?(Hash)
          options = args.pop
          options[:timeout]
        end

        timeout ||= 0
        unless timeout.is_a?(Integer) || timeout.is_a?(Float)
          raise ArgumentError, "timeout must be an Integer or Float, got: #{timeout.class}"
        end

        args.flatten!(1)
        command = [cmd].concat(args)
        command << timeout
        send_blocking_command(command, timeout, &blk)
      end

      def _movem_amount_args(count, exactly, order)
        raise ArgumentError, "Pick either count or exactly, not both" if count && exactly

        if count || exactly
          order = order.to_s.upcase
          raise ArgumentError, "order must be 'OBO' or 'BULK'" if order != "OBO" && order != "BULK"

          [count ? "COUNT" : "EXACTLY", Integer(count || exactly), order]
        elsif order
          raise ArgumentError, "order requires count or exactly"

View on GitHub (pinned to 2ba9010b91)

Solutions

  1. Pass the timeout as an Integer or Float number of seconds, e.g. timeout: 5 or timeout: 0.5.
  2. Convert the value before calling, e.g. timeout: timeout.to_f, if it comes in as a string.

When it happens

Trigger: Thrown at lib/redis/commands/lists.rb:392 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of redis/redis-rb@2ba9010b91 (2026-08-23). Data as JSON: /api/errors/9bd15ded26b34677. Report an issue: GitHub.