Skip to content

Commit 5cecb1b

Browse files
aviatcoaviat cohen
andauthored
fix: Update args parameter regex to allow optional whitespace after commas (#133)
Co-authored-by: aviat cohen <aviatcohen@microsoft.com>
1 parent e70ab4c commit 5cecb1b

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: fixed
2+
body: Update the argument-parameter regex to allow optional whitespace after commas
3+
time: 2026-01-12T14:11:04.576274188Z
4+
custom:
5+
Author: aviatco
6+
AuthorLink: https://github.com/aviatco

src/fabric_cli/utils/fab_util.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def remove_dot_suffix(path: str, dot_string_to_rm: str = ".Shortcut") -> str:
6262
return path.replace(dot_string_to_rm, "").replace(dot_string_to_rm.lower(), "")
6363

6464

65-
6665
def get_dict_from_params(params: str | list[str], max_depth: int = 2) -> dict:
6766
"""
6867
Convert args to dict with a specified max nested level.
@@ -76,7 +75,7 @@ def get_dict_from_params(params: str | list[str], max_depth: int = 2) -> dict:
7675
# Result ['key1.key2=hello', 'key2={"hello":"testing","bye":2}', 'key3=[1,2,3]', 'key4={"key5":"value5"}']
7776
# Example key1.key2=hello
7877
# Result ['key1.key=hello']
79-
pattern = r"((?:[\w\.]+=.+?)(?=(?:,[\w\.]+=)|$))"
78+
pattern = r"((?:[\w\.]+=.+?)(?=(?:,\s*[\w\.]+=)|$))"
8079

8180
if params:
8281
if isinstance(params, list):
@@ -166,8 +165,6 @@ def remove_keys_from_dict(_dict: dict, keys: list) -> dict:
166165
return _dict
167166

168167

169-
170-
171168
def get_os_specific_command(command: str) -> str:
172169
if platform.system() == "Windows":
173170
return fab_constant.OS_COMMANDS.get(command, {}).get("windows", command)
@@ -237,5 +234,3 @@ def get_capacity_settings(
237234
az_resource_group,
238235
sku,
239236
)
240-
241-

tests/test_utils/test_fab_util.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,40 @@ def test_get_dict_from_params():
138138
"desc3": "hi",
139139
}
140140

141+
# Test space after comma - this tests the regex pattern fix that allows spaces after commas
142+
params = "key1=value1, key2=value2, key3=value3"
143+
result = utils.get_dict_from_params(params)
144+
assert result == {"key1": "value1", "key2": "value2", "key3": "value3"}
145+
146+
# Test multiple spaces after comma
147+
params = "key1=value1, key2=value2, key3=value3"
148+
result = utils.get_dict_from_params(params)
149+
assert result == {"key1": "value1", "key2": "value2", "key3": "value3"}
150+
151+
# Test mixed spacing (some with spaces, some without)
152+
params = "key1=value1,key2=value2, key3=value3, key4=value4"
153+
result = utils.get_dict_from_params(params)
154+
assert result == {"key1": "value1", "key2": "value2", "key3": "value3", "key4": "value4"}
155+
156+
# Test with nested keys and spaces
157+
params = "key1.sub1=value1, key1.sub2=value2, key2=value3"
158+
result = utils.get_dict_from_params(params)
159+
assert result == {"key1": {"sub1": "value1", "sub2": "value2"}, "key2": "value3"}
160+
161+
# Test with complex values and spaces
162+
params = 'key1={"nested": "value"}, key2=[1,2,3], key3=simple'
163+
result = utils.get_dict_from_params(params)
164+
assert result == {
165+
"key1": '{nested: value}',
166+
"key2": "[1,2,3]",
167+
"key3": "simple"
168+
}
169+
170+
# Test tabs and mixed whitespace after comma
171+
params = "key1=value1,\tkey2=value2,\n key3=value3"
172+
result = utils.get_dict_from_params(params)
173+
assert result == {"key1": "value1", "key2": "value2", "key3": "value3"}
174+
141175

142176
def test_merge_dicts():
143177
dict1 = {"key1": "value1", "key2": {"key1": "value2"}}

0 commit comments

Comments
 (0)