From 5a931ad4b100536bb270c2fc8891a6af3d23f6e0 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 21 Nov 2026 17:28:04 +0100 Subject: [PATCH] fix: stop on an unreadable retrodeck manifest The local manifest read printed a warning and left the component out of retrodeck.yml with exit 0, where the remote read raises. --- scripts/scraper/retrodeck_scraper.py | 7 +++++-- tests/test_scraper_dropped.py | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/scraper/retrodeck_scraper.py b/scripts/scraper/retrodeck_scraper.py index 40fb6bf7b..97d05acac 100644 --- a/scripts/scraper/retrodeck_scraper.py +++ b/scripts/scraper/retrodeck_scraper.py @@ -448,11 +448,14 @@ class Scraper(BaseScraper): mf = d / "component_manifest.json" if not mf.exists(): continue + # Skipped with a warning, an unreadable manifest left its + # component's systems out of retrodeck.yml, exit code 0, where + # the remote read stops. try: with open(mf) as f: manifests.append((d.name, json.load(f))) - except (json.JSONDecodeError, OSError) as e: - print(f" WARNING: {mf}: {e}", file=sys.stderr) + except json.JSONDecodeError as e: + raise ValueError(f"{mf}: not JSON: {e}") from e return manifests def component_file(self, path: str) -> str | None: diff --git a/tests/test_scraper_dropped.py b/tests/test_scraper_dropped.py index f28c7ebce..989793a96 100644 --- a/tests/test_scraper_dropped.py +++ b/tests/test_scraper_dropped.py @@ -52,6 +52,14 @@ class RetrodeckConflicts(unittest.TestCase): scraper.fetch_requirements() self.assertEqual(scraper.dropped, []) + def test_an_unreadable_local_manifest_stops_the_scrape(self) -> None: + with tempfile.TemporaryDirectory() as tmp: + folder = Path(tmp) / "np2kai" + folder.mkdir() + (folder / "component_manifest.json").write_text("{") + with self.assertRaises(ValueError): + retrodeck_scraper.Scraper(manifests_dir=tmp).fetch_requirements() + class RommUnmappedSlug(unittest.TestCase): def test_an_unmapped_slug_fails_the_scrape(self) -> None: