Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contrib/batch_scan/batch_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _main_impl() -> None:
type=int,
default=4,
metavar="N",
help="Number of parallel scan workers (default: 4). "
help="Number of parallel scan workers (positive integer, default: 4). "
"Reduce to 1 for free-tier API keys, increase for enterprise tiers. "
"Skills that time out (90s of scanning, plus up to 90s for startup) "
"are reported as errors; other workers continue.",
Expand Down Expand Up @@ -357,6 +357,8 @@ def _main_impl() -> None:
help="Allow non-English scans without LLM (results will be incomplete).",
)
args = parser.parse_args()
if args.workers < 1:
parser.error("--workers must be a positive integer")

# Structured reports must not share stdout with progress or diagnostics.
progress_file = sys.stdout if args.format == "terminal" else sys.stderr
Expand Down
33 changes: 33 additions & 0 deletions tests/test_batch_scan_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,36 @@ def test_batch_cli_validation_errors_go_to_stderr(
captured = capsys.readouterr()
assert captured.out == ""
assert "is not a directory" in " ".join(captured.err.split())


@pytest.mark.parametrize("workers", ["0", "-2"])
def test_batch_cli_rejects_nonpositive_worker_counts(
batch_cli, monkeypatch: pytest.MonkeyPatch, capsys, tmp_path: Path, workers: str
) -> None:
root, _ = batch_cli
output = tmp_path / "report.json"
monkeypatch.setattr(
sys,
"argv",
[
"batch_scan",
str(root),
"--no-llm",
"--format",
"json",
"--workers",
workers,
"--output",
str(output),
],
)

with pytest.raises(SystemExit) as exc:
batch_scan._main_impl()

assert exc.value.code == 2
captured = capsys.readouterr()
assert captured.out == ""
assert "--workers must be a positive integer" in captured.err
assert "SkillSpector Batch Scan" not in captured.err
assert not output.exists()
Loading