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 <gabriel.erzse@redis.com>
  • Loading branch information
2 people authored and vladvildanov committed Sep 27, 2024
1 parent 4bc034a commit 443a9cc
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 443a9cc

Please sign in to comment.