Skip to content

Commit 26d2d13

Browse files
authored
Fix parsing of INFO response (#3264)
If the INFO response contains a single `a=b` value for any of the keys, that must also be parsed into a dictionary. Fixes #3262 Co-authored-by: Gabriel Erzse <gabriel.erzse@redis.com>
1 parent e71119d commit 26d2d13

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

redis/_parsers/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def parse_info(response):
3838
response = str_if_bytes(response)
3939

4040
def get_value(value):
41-
if "," not in value or "=" not in value:
41+
if "," not in value and "=" not in value:
4242
try:
4343
if "." in value:
4444
return float(value)

tests/test_parsers/test_helpers.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from redis._parsers.helpers import parse_info
2+
3+
4+
def test_parse_info():
5+
info_output = """
6+
# Modules
7+
module:name=search,ver=999999,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors]
8+
9+
# search_fields_statistics
10+
search_fields_text:Text=3
11+
search_fields_tag:Tag=2,Sortable=1
12+
13+
# search_version
14+
search_version:99.99.99
15+
search_redis_version:7.2.2 - oss
16+
17+
# search_runtime_configurations
18+
search_query_timeout_ms:500
19+
"""
20+
info = parse_info(info_output)
21+
22+
assert isinstance(info["modules"], list)
23+
assert isinstance(info["modules"][0], dict)
24+
assert info["modules"][0]["name"] == "search"
25+
26+
assert isinstance(info["search_fields_text"], dict)
27+
assert info["search_fields_text"]["Text"] == 3
28+
29+
assert isinstance(info["search_fields_tag"], dict)
30+
assert info["search_fields_tag"]["Tag"] == 2
31+
assert info["search_fields_tag"]["Sortable"] == 1
32+
33+
assert info["search_version"] == "99.99.99"
34+
assert info["search_redis_version"] == "7.2.2 - oss"
35+
assert info["search_query_timeout_ms"] == 500

0 commit comments

Comments
 (0)