From 349f78b8ed9509e2806beb4e70adbdde33615b3e Mon Sep 17 00:00:00 2001 From: Gabriel Erzse Date: Fri, 24 May 2024 10:23:32 +0300 Subject: [PATCH] Parse FT.PROFILE response more robustly When parsing the response of FT.PROFILE, handle the cases when the nested items are either not lists, or empty lists, or lists with a single item. --- redis/commands/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redis/commands/helpers.py b/redis/commands/helpers.py index 127141f650..1ea02a60cf 100644 --- a/redis/commands/helpers.py +++ b/redis/commands/helpers.py @@ -85,7 +85,11 @@ def parse_to_dict(response): res = {} for det in response: - if isinstance(det[1], list): + if not isinstance(det, list) or not det: + continue + if len(det) == 1: + res[det[0]] = True + elif isinstance(det[1], list): res[det[0]] = parse_list_to_dict(det[1]) else: try: # try to set the attribute. may be provided without value