{"record":{"id":"78fb79fe1b956f33","repo":"redis/redis-rb","slug":"count-argument-must-be-specified-78fb79","errorCode":null,"errorMessage":"count argument must be specified","messagePattern":"count argument must be specified","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/sorted_sets.rb","lineNumber":330,"sourceCode":"      #   redis.zrandmember(\"zset\", 2)\n      #     # => [\"a\", \"b\"]\n      # @example Get multiple random members with scores\n      #   redis.zrandmember(\"zset\", 2, with_scores: true)\n      #     # => [[\"a\", 2.0], [\"b\", 3.0]]\n      #\n      # @param [String] key\n      # @param [Integer] count\n      # @param [Hash] options\n      #   - `:with_scores => true`: include scores in output\n      #\n      # @return [nil, String, Array<String>, Array<[String, Float]>]\n      #   - when `key` does not exist or set is empty, `nil`\n      #   - when `count` is not specified, a member\n      #   - when `count` is specified and `:with_scores` is not specified, an array of members\n      #   - when `:with_scores` is specified, an array with `[member, score]` pairs\n      def zrandmember(key, count = nil, withscores: false, with_scores: withscores)\n        if with_scores && count.nil?\n          raise ArgumentError, \"count argument must be specified\"\n        end\n\n        args = [:zrandmember, key]\n        args << Integer(count) if count\n\n        if with_scores\n          args << \"WITHSCORES\"\n          block = FloatifyPairs\n        end\n\n        send_command(args, &block)\n      end\n\n      # Return a range of members in a sorted set, by index, score or lexicographical ordering.\n      #\n      # @example Retrieve all members from a sorted set, by index\n      #   redis.zrange(\"zset\", 0, -1)\n      #     # => [\"a\", \"b\"]","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/sorted_sets.rb#L312-L348","documentation":"Error \"count argument must be specified\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/commands/sorted_sets.rb:330 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the count: keyword argument; this command variant requires an explicit count.","Use the non-count variant of the command if you do not want to limit results."],"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"}