diff --git a/src/hflow/curation.py b/src/hflow/curation.py index 7a95a369..9e072366 100644 --- a/src/hflow/curation.py +++ b/src/hflow/curation.py @@ -813,6 +813,10 @@ def stale_episodes( comparison. Feed each result's ``source_uri`` back into ingestion (``hflow ingest`` / ``app.process``) to reprocess it. """ + if not pipeline_version.strip(): + # A blank version differs from every cataloged one, so it would + # report the whole corpus as stale and queue all of it for re-ingest. + raise ValueError("pipeline_version must not be blank") connection = open_catalog_connection(catalog_root) try: predicate = "pipeline_version IS DISTINCT FROM ?" diff --git a/tests/test_catalog_curation.py b/tests/test_catalog_curation.py index 0846f37c..5025ed6c 100644 --- a/tests/test_catalog_curation.py +++ b/tests/test_catalog_curation.py @@ -1141,6 +1141,44 @@ def test_cli_stale_prints_source_uris_for_ingest( assert "1 episode(s)" in captured.err +@pytest.mark.parametrize("blank_version", ["", " "]) +def test_cli_stale_rejects_a_blank_pipeline_version( + tmp_path: Path, capsys: pytest.CaptureFixture[str], blank_version: str +) -> None: + catalog = Catalog(tmp_path / "catalog") + catalog.append_episode( + canonical_path=write_fake_canonical(tmp_path), + stamps=FAKE_STAMPS, + episode_metadata={}, + check_rows=[], + source_uri="episodes-in/run_0001.mcap", + ) + exit_code = cli_main( + [ + "stale", + "--catalog", + str(tmp_path / "catalog"), + "--pipeline-version", + blank_version, + ] + ) + assert exit_code == 2 + captured = capsys.readouterr() + # A blank version differs from every cataloged one, so it would list the + # whole corpus for re-ingest. Nothing pipeable may reach stdout. + assert captured.out == "" + assert "pipeline_version must not be blank" in captured.err + + +@pytest.mark.parametrize("blank_version", ["", " "]) +def test_stale_episodes_rejects_a_blank_pipeline_version( + tmp_path: Path, blank_version: str +) -> None: + Catalog(tmp_path / "catalog") + with pytest.raises(ValueError, match="pipeline_version must not be blank"): + hflow.stale_episodes(tmp_path / "catalog", pipeline_version=blank_version) + + def test_cli_stale_rejects_pipeline_and_pipeline_version_together( tmp_path: Path, capsys: pytest.CaptureFixture[str] ) -> None: