Skip to content

Commit 1f04181

Browse files
gerzseaiven-sal
authored andcommitted
Parse FT.PROFILE response more robustly (redis#3245)
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]> Signed-off-by: Salvatore Mesoraca <[email protected]>
1 parent 40372b3 commit 1f04181

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

valkey/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)