{"record":{"id":"5f3e876e1141cecb","repo":"redis/redis-rb","slug":"can-t-supply-both-maxlen-and-minid","errorCode":null,"errorMessage":"can't supply both maxlen and minid","messagePattern":"can't supply both maxlen and minid","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/streams.rb","lineNumber":55,"sourceCode":"      #   redis.xadd('mystream', { f1: 'v1', f2: 'v2' }, id: '0-0', maxlen: 1000, approximate: true, nomkstream: true)\n      #\n      # @param key   [String] the stream key\n      # @param entry [Hash]   one or multiple field-value pairs\n      # @param opts  [Hash]   several options for `XADD` command\n      #\n      # @option opts [String]  :id          the entry id, default value is `*`, it means auto generation\n      # @option opts [Integer] :maxlen      max length of entries to keep\n      # @option opts [Integer] :minid       min id of entries to keep\n      # @option opts [Boolean] :approximate whether to add `~` modifier of maxlen/minid or not\n      # @option opts [Integer] :limit       maximum count of entries to be evicted, requires approximate trimming\n      # @option opts [Boolean] :nomkstream  whether to add NOMKSTREAM, default is not to add\n      #\n      # @return [String] the entry id\n      def xadd(key, entry, approximate: nil, maxlen: nil, minid: nil, limit: nil, nomkstream: nil, id: '*')\n        args = [:xadd, key]\n        args << 'NOMKSTREAM' if nomkstream\n        if maxlen\n          raise ArgumentError, \"can't supply both maxlen and minid\" if minid\n\n          args << \"MAXLEN\"\n          args << \"~\" if approximate\n          args << maxlen\n        elsif minid\n          args << \"MINID\"\n          args << \"~\" if approximate\n          args << minid\n        end\n        args.concat(['LIMIT', limit]) if limit\n        args << id\n        args.concat(entry.flatten)\n        send_command(args)\n      end\n\n      # Trims older entries of the stream if needed.\n      #\n      # @example Without options","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/streams.rb#L37-L73","documentation":"Error \"can't supply both maxlen and minid\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/commands/streams.rb:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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"}