From 8e34b81f89440705c946d5233819c5f822173d53 Mon Sep 17 00:00:00 2001 From: dipakchaudhari12717 Date: Mon, 20 Jul 2026 20:19:14 +0530 Subject: [PATCH] fix(cli): error when --side-csv is named but missing instead of stubbing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _ensure_side_csv synthesised a header-only stub whenever the file was absent — including when the user explicitly passed a path with a typo, masking the mistake. Now only an unspecified --side-csv stubs; a named missing path gets parser.error, matching --dose-csv/--layer-csv. Fixes #19 --- src/steerbench/cli.py | 5 +++++ tests/test_cli.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/steerbench/cli.py b/src/steerbench/cli.py index c0f1e29..9e85f3d 100644 --- a/src/steerbench/cli.py +++ b/src/steerbench/cli.py @@ -124,6 +124,11 @@ def main(argv: list[str] | None = None) -> int: if not csv_path.exists(): parser.error(f"{label} CSV not found: {csv_path}") + # An explicitly named side CSV must exist; only an *unspecified* one may + # fall back to the header-only stub. + if args.side_csv is not None and not args.side_csv.exists(): + parser.error(f"side-effects CSV not found: {args.side_csv}") + side_csv = _ensure_side_csv(args.side_csv, args.out) outputs = report.build_report( dose_csv=args.dose_csv, diff --git a/tests/test_cli.py b/tests/test_cli.py index 48de874..87c3f7e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -67,3 +67,25 @@ def test_cli_json_emits_artifact_paths(tmp_path: Path, capsys: pytest.CaptureFix def test_cli_errors_on_missing_csv(tmp_path: Path) -> None: with pytest.raises(SystemExit): cli.main(["--dose-csv", str(tmp_path / "nope.csv"), "--out", str(tmp_path / "o")]) + + +def test_cli_errors_on_missing_named_side_csv( + tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + # An explicitly named --side-csv that doesn't exist must error, not + # silently fall back to the header-only stub (that's for unspecified only). + with pytest.raises(SystemExit) as exc: + cli.main( + [ + "--dose-csv", + str(_DOSE), + "--layer-csv", + str(_LAYER), + "--side-csv", + str(tmp_path / "typo.csv"), + "--out", + str(tmp_path / "o"), + ] + ) + assert exc.value.code != 0 + assert "side-effects CSV not found" in capsys.readouterr().err