redis/redis-rb · error · ArgumentError
can't supply both maxlen and minid
Error message
can't supply both maxlen and minid
What it means
Error "can't supply both maxlen and minid" thrown in redis/redis-rb.
Source
Thrown at lib/redis/commands/streams.rb:55
# redis.xadd('mystream', { f1: 'v1', f2: 'v2' }, id: '0-0', maxlen: 1000, approximate: true, nomkstream: true)
#
# @param key [String] the stream key
# @param entry [Hash] one or multiple field-value pairs
# @param opts [Hash] several options for `XADD` command
#
# @option opts [String] :id the entry id, default value is `*`, it means auto generation
# @option opts [Integer] :maxlen max length of entries to keep
# @option opts [Integer] :minid min id of entries to keep
# @option opts [Boolean] :approximate whether to add `~` modifier of maxlen/minid or not
# @option opts [Integer] :limit maximum count of entries to be evicted, requires approximate trimming
# @option opts [Boolean] :nomkstream whether to add NOMKSTREAM, default is not to add
#
# @return [String] the entry id
def xadd(key, entry, approximate: nil, maxlen: nil, minid: nil, limit: nil, nomkstream: nil, id: '*')
args = [:xadd, key]
args << 'NOMKSTREAM' if nomkstream
if maxlen
raise ArgumentError, "can't supply both maxlen and minid" if minid
args << "MAXLEN"
args << "~" if approximate
args << maxlen
elsif minid
args << "MINID"
args << "~" if approximate
args << minid
end
args.concat(['LIMIT', limit]) if limit
args << id
args.concat(entry.flatten)
send_command(args)
end
# Trims older entries of the stream if needed.
#
# @example Without optionsView on GitHub (pinned to 2ba9010b91)
Solutions
- Trim by either maxlen: or minid:, not both, in the same call.
- Issue two separate commands if you need both trimming strategies applied sequentially.
When it happens
Trigger: Thrown at lib/redis/commands/streams.rb:55 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/5f3e876e1141cecb.
Report an issue: GitHub.