Skip to content

Commit 174421b

Browse files
zkoppertCopilot
andcommitted
fix: tolerate trailing commas in EXEMPT_ECOSYSTEMS
Skip empty strings after split/strip instead of rejecting them as unrecognized ecosystems. A trailing comma (e.g. 'npm,docker,') was previously harmless and should remain so. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8d48234 commit 174421b

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ def get_env_vars(
304304
if exempt_ecosystems:
305305
for ecosystem in exempt_ecosystems.split(","):
306306
ecosystem = ecosystem.lower().strip()
307+
if not ecosystem:
308+
continue
307309
if ecosystem not in SUPPORTED_PACKAGE_ECOSYSTEMS:
308310
raise ValueError(
309311
f"EXEMPT_ECOSYSTEMS environment variable contains an unrecognized package-ecosystem: '{ecosystem}'."

test_env.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,22 @@ def test_get_env_vars_exempt_ecosystems_unsupported_ecosystem(self):
944944
"EXEMPT_ECOSYSTEMS environment variable contains an unrecognized package-ecosystem: 'docekr'.",
945945
)
946946

947+
@patch.dict(
948+
os.environ,
949+
{
950+
"ORGANIZATION": "my_organization",
951+
"GH_TOKEN": "my_token",
952+
"ENABLE_SECURITY_UPDATES": "false",
953+
"FILTER_VISIBILITY": "private,public",
954+
"EXEMPT_ECOSYSTEMS": "gomod,docker,",
955+
},
956+
clear=True,
957+
)
958+
def test_get_env_vars_exempt_ecosystems_trailing_comma(self):
959+
"""Test that EXEMPT_ECOSYSTEMS tolerates trailing commas"""
960+
result = get_env_vars(True)
961+
self.assertEqual(result[21], ["gomod", "docker"])
962+
947963
@patch.dict(
948964
os.environ,
949965
{

0 commit comments

Comments
 (0)