From 5d9624e70e481cf1d6a215ba0a05fdb28d5a52bd Mon Sep 17 00:00:00 2001 From: vladvildanov Date: Tue, 19 Nov 2024 11:01:30 +0200 Subject: [PATCH] Fixed bug with SLOWLOG GET response parsing from Redis Enterprise --- redis/_parsers/helpers.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/redis/_parsers/helpers.py b/redis/_parsers/helpers.py index 6832100bb6..5468addf62 100644 --- a/redis/_parsers/helpers.py +++ b/redis/_parsers/helpers.py @@ -396,13 +396,20 @@ def parse_item(item): # an O(N) complexity) instead of the command. if isinstance(item[3], list): result["command"] = space.join(item[3]) - result["client_address"] = item[4] - result["client_name"] = item[5] + + # These fields are optional, depends on environment. + if len(item) >= 6: + result["client_address"] = item[4] + result["client_name"] = item[5] else: result["complexity"] = item[3] result["command"] = space.join(item[4]) - result["client_address"] = item[5] - result["client_name"] = item[6] + + # These fields are optional, depends on environment. + if len(item) >= 7: + result["client_address"] = item[5] + result["client_name"] = item[6] + return result return [parse_item(item) for item in response]