{"record":{"id":"06d5dc66bedd466e","repo":"redis/redis-rb","slug":"only-one-of-by-score-or-by-lex-can-be-specified","errorCode":null,"errorMessage":"only one of :by_score or :by_lex can be specified","messagePattern":"only one of :by_score or :by_lex can be specified","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/sorted_sets.rb","lineNumber":370,"sourceCode":"      #\n      # @param [String] key\n      # @param [Integer] start start index\n      # @param [Integer] stop stop index\n      # @param [Hash] options\n      #   - `:by_score => false`: return members by score\n      #   - `:by_lex => false`: return members by lexicographical ordering\n      #   - `:rev => false`: reverse the ordering, from highest to lowest\n      #   - `:limit => [offset, count]`: skip `offset` members, return a maximum of\n      #   `count` members\n      #   - `:with_scores => true`: include scores in output\n      #\n      # @return [Array<String>, Array<[String, Float]>]\n      #   - when `:with_scores` is not specified, an array of members\n      #   - when `:with_scores` is specified, an array with `[member, score]` pairs\n      def zrange(key, start, stop, byscore: false, by_score: byscore, bylex: false, by_lex: bylex,\n                 rev: false, limit: nil, withscores: false, with_scores: withscores)\n        if by_score && by_lex\n          raise ArgumentError, \"only one of :by_score or :by_lex can be specified\"\n        end\n\n        args = [:zrange, key, start, stop]\n\n        if by_score\n          args << \"BYSCORE\"\n        elsif by_lex\n          args << \"BYLEX\"\n        end\n\n        args << \"REV\" if rev\n\n        if limit\n          args << \"LIMIT\"\n          args.concat(limit.map { |l| Integer(l) })\n        end\n\n        if with_scores","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/sorted_sets.rb#L352-L388","documentation":"Error \"only one of :by_score or :by_lex can be specified\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/commands/sorted_sets.rb:370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass only one of :by_score or :by_lex.","Choose by_score for score ranges or by_lex for lexicographical ranges, and drop the other flag."],"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"}