Repository: redis/redis-py
Pull request #3063 (2023-12-03 23:54:14)

Fix parsing of `FT.PROFILE` result
### Description of change

Fix the parsing of ft.profile result - before this fix, if there are more than 2 child iterators some of them are skipped (because the loop is in pairs), and the result is wrong

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/redis/redis-py/pull/3063?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis) Report
Attention: `1 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`6978275`)](https://app.codecov.io/gh/redis/redis-py/commit/69782750343496b7b88bf82c006f4205afd7aabd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis) 91.16% compared to head [(`59f8d2c`)](https://app.codecov.io/gh/redis/redis-py/pull/3063?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis) 77.59%.
> Report is 7 commits behind head on master.

| [Files](https://app.codecov.io/gh/redis/redis-py/pull/3063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis) | Patch % | Lines |
|---|---|---|
| [redis/commands/helpers.py](https://app.codecov.io/gh/redis/redis-py/pull/3063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis#diff-cmVkaXMvY29tbWFuZHMvaGVscGVycy5weQ==) | 80.00% | [1 Missing :warning: ](https://app.codecov.io/gh/redis/redis-py/pull/3063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis) |

:exclamation: Your organization needs to install the [Codecov GitHub app](https://github.com/apps/codecov/installations/select_target) to enable full functionality.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff             @@
##           master    #3063       +/-   ##
===========================================
- Coverage   91.16%   77.59%   -13.57%     
===========================================
  Files         127      127               
  Lines       32846    32855        +9     
===========================================
- Hits        29944    25495     -4449     
- Misses       2902     7360     +4458     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/redis/redis-py/pull/3063?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis).


Patch:
diff --git a/redis/commands/helpers.py b/redis/commands/helpers.py
index 324d981d..127141f6 100644
--- a/redis/commands/helpers.py
+++ b/redis/commands/helpers.py
@@ -64,6 +64,11 @@ def parse_list_to_dict(response):
     for i in range(0, len(response), 2):
         if isinstance(response[i], list):
             res["Child iterators"].append(parse_list_to_dict(response[i]))
+            try:
+                if isinstance(response[i + 1], list):
+                    res["Child iterators"].append(parse_list_to_dict(response[i + 1]))
+            except IndexError:
+                pass
         elif isinstance(response[i + 1], list):
             res["Child iterators"] = [parse_list_to_dict(response[i + 1])]
         else:


Test patch:
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 57a94d2f..66ee1c53 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -41,6 +41,7 @@ def test_parse_to_dict():
                 "Child iterators",
                 ["Type", "bar", "Time", "0.0729", "Counter", 3],
                 ["Type", "barbar", "Time", "0.058", "Counter", 3],
+                ["Type", "barbarbar", "Time", "0.0234", "Counter", 3],
             ],
         ],
     ]
@@ -49,6 +50,7 @@ def test_parse_to_dict():
             "Child iterators": [
                 {"Counter": 3.0, "Time": 0.0729, "Type": "bar"},
                 {"Counter": 3.0, "Time": 0.058, "Type": "barbar"},
+                {"Counter": 3.0, "Time": 0.0234, "Type": "barbarbar"},
             ],
             "Counter": 3.0,
             "Time": 0.2089,