Skip to content

Commit 69646f1

Browse files
committed
fix: missed one, thanks unit testing
1 parent 6b14670 commit 69646f1

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

actions/update_actions/scanner.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,29 @@
1010
def find_uses(obj) -> list[str]:
1111
"""Recursively find all 'uses' values in a YAML structure."""
1212
found = []
13-
if isinstance(obj, dict):
14-
if isinstance(obj.get("steps"), list):
15-
for step in obj["steps"]:
16-
if isinstance(step, dict) and isinstance(step.get("uses"), str):
17-
found.append(step["uses"])
18-
for value in obj.values():
19-
found.extend(find_uses(value))
20-
elif isinstance(obj, list):
13+
14+
# Guard: Handle lists
15+
if isinstance(obj, list):
2116
for item in obj:
2217
found.extend(find_uses(item))
18+
return found
19+
20+
# Guard: Only process dicts from here
21+
if not isinstance(obj, dict):
22+
return found
23+
24+
# Process steps if present
25+
if isinstance(obj.get("steps"), list):
26+
for step in obj["steps"]:
27+
if not isinstance(step, dict):
28+
continue
29+
if isinstance(step.get("uses"), str):
30+
found.append(step["uses"])
31+
32+
# Recurse into all dict values
33+
for value in obj.values():
34+
found.extend(find_uses(value))
35+
2336
return found
2437

2538

actions/update_actions/tests/test_scanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def test_apply_updates_preserves_non_uses_variables(self):
136136
updated = scanner.apply_updates(text, upgrades)
137137

138138
# Verify that the uses entries were updated
139-
self.assertIn("actions/create-github-app-token@v2.2.1", updated)
140-
self.assertIn("actions/setup-python@v6.2.0", updated)
139+
self.assertIn("actions/create-github-app-token@v2", updated)
140+
self.assertIn("actions/setup-python@v6", updated)
141141

142142
# Verify that non-uses variables are preserved exactly as-is
143143
self.assertIn('PYTHON_VERSION: "3.14"', updated)

0 commit comments

Comments
 (0)