Skip to content

Commit 482c47f

Browse files
committed
Propagate missing file errors
Re-raise FileNotFoundError after logging in the VTT and HTML converters so bulk conversion records missing input files as failures instead of successes. Add regression coverage for database-driven missing VTT references and converter-level missing file propagation. Validation: uv run --locked pytest Model settings: GPT-5 Codex Thread ID: 019f3312-699f-7fb0-aa6d-4d8a7dfb8196
1 parent 12bdc67 commit 482c47f

5 files changed

Lines changed: 43 additions & 4 deletions

File tree

podcast_transcript_convert/converters/html_to_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ def html_file_to_json_file(
8080
raise
8181
except FileNotFoundError:
8282
logger.error(f"File not found: {html_file}")
83-
return
83+
raise
8484

8585
write_text_utf8(json_file, dumps(transcript_dict, indent=4))

podcast_transcript_convert/converters/vtt_to_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ def vtt_file_to_json_file(
5252
raise
5353
except FileNotFoundError:
5454
logger.error(f"File not found: {vtt_file}")
55-
return
55+
raise
5656
write_text_utf8(json_file, dumps(transcript_dict, indent=4))

tests/test_convert.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,34 @@ def test_bulk_convert_continues_after_failure(tmp_path: Path):
9999
assert (destination / "good.json").exists()
100100

101101

102+
def test_bulk_convert_records_missing_vtt_as_failure(
103+
tmp_path: Path,
104+
monkeypatch: pytest.MonkeyPatch,
105+
):
106+
missing = tmp_path / "missing.vtt"
107+
destination = tmp_path / "out"
108+
109+
def missing_vtt_from_db(
110+
db_path: str,
111+
ignore: list[str],
112+
) -> tuple[list[str], dict[str, dict[str, str]]]:
113+
assert db_path == str(tmp_path / "overcast.db")
114+
assert ignore == []
115+
return [str(missing)], {}
116+
117+
monkeypatch.setattr(
118+
convert_module,
119+
"list_files_from_db",
120+
missing_vtt_from_db,
121+
)
122+
123+
summary = convert_module.bulk_convert(str(tmp_path / "overcast.db"), str(destination))
124+
125+
assert summary.converted == []
126+
assert [src for src, _ in summary.failed] == [str(missing)]
127+
assert list(destination.rglob("*.json")) == []
128+
129+
102130
def test_bulk_convert_skips_existing_unless_overwrite(tmp_path: Path):
103131
source = tmp_path / "in"
104132
source.mkdir()

tests/test_html.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from podcast_transcript_convert.converters.html_to_json import (
66
_ts_to_secs,
7+
html_file_to_json_file,
78
html_to_podcast_dict,
89
)
910
from podcast_transcript_convert.errors import InvalidHtmlError
@@ -85,3 +86,12 @@ def test_html_to_podcast_dict_with_ts_looking_in_body():
8586
def test_html_to_podcast_dict_empty():
8687
with pytest.raises(InvalidHtmlError):
8788
html_to_podcast_dict("")
89+
90+
91+
def test_html_file_to_json_file_missing_file_raises(tmp_path: Path):
92+
destination = tmp_path / "out.json"
93+
94+
with pytest.raises(FileNotFoundError):
95+
html_file_to_json_file(tmp_path / "missing.html", destination, None)
96+
97+
assert not destination.exists()

tests/test_vtt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ def test_vtt_to_podcast_dict_with_invalid():
7474
vtt_to_podcast_dict("")
7575

7676

77-
def test_vtt_file_to_json_file_missing_file_returns(tmp_path: Path):
77+
def test_vtt_file_to_json_file_missing_file_raises(tmp_path: Path):
7878
destination = tmp_path / "out.json"
7979

80-
vtt_file_to_json_file(tmp_path / "missing.vtt", destination, None)
80+
with pytest.raises(FileNotFoundError):
81+
vtt_file_to_json_file(tmp_path / "missing.vtt", destination, None)
8182

8283
assert not destination.exists()

0 commit comments

Comments
 (0)