redis/redis-rb · error · ArgumentError

only one of :nx, :xx, :gt, :lt can be specified

Error message

only one of :nx, :xx, :gt, :lt can be specified

What it means

Error "only one of :nx, :xx, :gt, :lt can be specified" thrown in redis/redis-rb.

Source

Thrown at lib/redis/commands/hashes.rb:558

      #   future minor release without a major version bump.
      #
      # @return [Integer] number of fieldsets removed
      # @api experimental
      def himport_discard_all
        send_command([:himport, "DISCARDALL"])
      end

      private

      # The HEXPIRE command family accepts a single optional condition token
      # (`[NX | XX | GT | LT]`); the server rejects combinations, so fail fast in Ruby.
      def hash_field_expiration_condition(nx, xx, gt, lt)
        condition = []
        condition << "NX" if nx
        condition << "XX" if xx
        condition << "GT" if gt
        condition << "LT" if lt
        raise ArgumentError, "only one of :nx, :xx, :gt, :lt can be specified" if condition.size > 1

        condition
      end
    end
  end
end

View on GitHub (pinned to 2ba9010b91)

Solutions

  1. Pass only one of the mutually exclusive options :nx, :xx, :gt or :lt.
  2. Remove the extra option(s) from the keyword arguments so exactly one condition flag remains.

When it happens

Trigger: Thrown at lib/redis/commands/hashes.rb:558 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/203216b389800445. Report an issue: GitHub.