Skip to content

Commit 475caa3

Browse files
sbryngelsonclaude
andcommitted
Validate --shard argument format and bounds
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b5dfa1f commit 475caa3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

toolchain/mfc/test/test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ def __filter(cases_) -> typing.List[TestCase]:
100100
cases = [case for case in cases if case not in example_cases]
101101

102102
if ARG("shard") is not None:
103-
shard_idx, shard_count = (int(x) for x in ARG("shard").split("/"))
103+
parts = ARG("shard").split("/")
104+
if len(parts) != 2 or not all(p.isdigit() for p in parts) or int(parts[1]) < 1 or not 1 <= int(parts[0]) <= int(parts[1]):
105+
raise MFCException(f"Invalid --shard '{ARG('shard')}': expected 'i/n' with 1 <= i <= n (e.g., '1/2').")
106+
shard_idx, shard_count = int(parts[0]), int(parts[1])
104107
skipped_cases += [c for i, c in enumerate(cases) if i % shard_count != shard_idx - 1]
105108
cases = [c for i, c in enumerate(cases) if i % shard_count == shard_idx - 1]
106109

0 commit comments

Comments
 (0)