@@ -33,12 +33,26 @@ def parse_dict_or_list_param(
3333 Returns:
3434 dict | list | None: Parsed parameter or None if parsing fails
3535 """
36+
37+ def convert_string_booleans (obj ):
38+ if isinstance (obj , dict ):
39+ return {k : convert_string_booleans (v ) for k , v in obj .items ()}
40+ elif isinstance (obj , list ):
41+ return [convert_string_booleans (item ) for item in obj ]
42+ elif isinstance (obj , str ):
43+ if obj .lower () == "true" :
44+ return True
45+ elif obj .lower () == "false" :
46+ return False
47+ return obj
48+
3649 if value is None :
3750 return None
3851
3952 try :
4053 # Try parsing as JSON first
41- return json .loads (value )
54+ parsed = json .loads (value )
55+ return convert_string_booleans (parsed )
4256 except json .JSONDecodeError :
4357 try :
4458 # Try parsing as Python literal
@@ -50,13 +64,14 @@ def parse_dict_or_list_param(
5064 elif param_type == "list" and not isinstance (parsed , list ):
5165 raise ValueError (f"Expected list, got { type (parsed )} " )
5266
53- return parsed
67+ return convert_string_booleans ( parsed )
5468 except (SyntaxError , ValueError ):
5569 # For dicts, try parsing as comma-separated key=value pairs
5670 if param_type == "dict" and "=" in value :
57- return dict (
71+ parsed = dict (
5872 pair .split ("=" , 1 ) for pair in value .split ("," ) if pair .strip ()
5973 )
74+ return convert_string_booleans (parsed )
6075
6176 # For lists, try multiple parsing strategies
6277 if param_type == "list" :
@@ -70,7 +85,9 @@ def parse_dict_or_list_param(
7085 list_items = re .findall (r"['\"]?(.*?)['\"]?(?=\s*,|\s*$)" , value )
7186
7287 # Remove any empty strings and strip whitespace
73- return [item .strip () for item in list_items if item .strip ()]
88+ parsed = [item .strip () for item in list_items if item .strip ()]
89+
90+ return convert_string_booleans (parsed )
7491
7592 # If all parsing fails, log warning and return None
7693 logger .warning (f"Could not parse { param_type } parameter: { value } " )
0 commit comments