redis/redis-rb · error · ArgumentError

Pick either MIN or MAX

Error message

Pick either MIN or MAX

What it means

Error "Pick either MIN or MAX" thrown in redis/redis-rb.

Source

Thrown at lib/redis/commands/sorted_sets.rb:189

      #
      # @example Popping a member
      #   redis.bzmpop('zset')
      #   #=> ['zset', ['a', 1.0]]
      # @example With count option
      #   redis.bzmpop('zset', count: 2)
      #   #=> ['zset', [['a', 1.0], ['b', 2.0]]
      #
      # @params timeout [Float] a float value specifying the maximum number of seconds to block) elapses.
      #   A timeout of zero can be used to block indefinitely.
      # @params key [String, Array<String>] one or more keys with sorted sets
      # @params modifier [String]
      #  - when `"MIN"` - the elements popped are those with lowest scores
      #  - when `"MAX"` - the elements popped are those with the highest scores
      # @params count [Integer] a number of members to pop
      #
      # @return [Array<String, Array<String, Float>>] list of popped elements and scores
      def bzmpop(timeout, *keys, modifier: "MIN", count: nil)
        raise ArgumentError, "Pick either MIN or MAX" unless modifier == "MIN" || modifier == "MAX"

        args = [:bzmpop, timeout, keys.size, *keys, modifier]
        args << "COUNT" << Integer(count) if count

        send_blocking_command(args, timeout) do |response|
          response&.map do |entry|
            case entry
            when String then entry
            when Array then entry.map { |pair| FloatifyPairs.call(pair) }.flatten(1)
            end
          end
        end
      end

      # Removes and returns up to count members with scores in the sorted set stored at key.
      #
      # @example Popping a member
      #   redis.zmpop('zset')

View on GitHub (pinned to 2ba9010b91)

Solutions

  1. Pass either :min or :max as the aggregate/endpoint option, not both.
  2. Split the call into two separate calls if you need both MIN and MAX results.

When it happens

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

Common situations: See trigger scenarios.


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