Skip to content

Commit 349f78b

Browse files
committed
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.
1 parent 9908a4d commit 349f78b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

redis/commands/helpers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ def parse_to_dict(response):
8585

8686
res = {}
8787
for det in response:
88-
if isinstance(det[1], list):
88+
if not isinstance(det, list) or not det:
89+
continue
90+
if len(det) == 1:
91+
res[det[0]] = True
92+
elif isinstance(det[1], list):
8993
res[det[0]] = parse_list_to_dict(det[1])
9094
else:
9195
try: # try to set the attribute. may be provided without value

0 commit comments

Comments
 (0)