Skip to content

Commit

Permalink
Parse FT.PROFILE response more robustly (#3245)
Browse files Browse the repository at this point in the history
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.

Co-authored-by: Gabriel Erzse <[email protected]>
  • Loading branch information
gerzse and gerzse authored May 24, 2024
1 parent 9908a4d commit b7a85eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion redis/commands/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7a85eb

Please sign in to comment.