diff --git a/scripts/exporter/recalbox_exporter.py b/scripts/exporter/recalbox_exporter.py index 5e77ed86..95b01525 100644 --- a/scripts/exporter/recalbox_exporter.py +++ b/scripts/exporter/recalbox_exporter.py @@ -131,8 +131,13 @@ class Exporter(BaseExporter): if original: try: root = parse_untrusted_xml(original, self.native_filename(), comments=True) - except (ParseError, ValueError): - root = None + except (ParseError, ValueError) as exc: + # Rebuilt from our model alone, the export would drop every + # system we do not transcribe and the maintainer's comments. + raise ValueError( + f"Recalbox's {self.native_filename()} does not parse ({exc}); " + "fetch it again with --refresh-cache" + ) from exc if root is not None: theirs = [ (s.get("platform", ""), s.get("fullname", ""), [ diff --git a/scripts/exporter/retrobat_exporter.py b/scripts/exporter/retrobat_exporter.py index 5f5b96ed..22ce255c 100644 --- a/scripts/exporter/retrobat_exporter.py +++ b/scripts/exporter/retrobat_exporter.py @@ -69,8 +69,11 @@ class Exporter(BaseExporter): if original: try: base = json.loads(original, object_pairs_hook=OrderedDict) - except json.JSONDecodeError: - base = {} + except json.JSONDecodeError as exc: + raise ValueError( + f"RetroBat's {self.native_filename()} does not parse ({exc}); " + "fetch it again with --refresh-cache" + ) from exc exportable = { system.native_id: (system, files) diff --git a/tests/test_export_counts.py b/tests/test_export_counts.py index 4b6ff16c..5d6da8f2 100644 --- a/tests/test_export_counts.py +++ b/tests/test_export_counts.py @@ -762,5 +762,29 @@ class AStaleTruthIsRefused(unittest.TestCase): export_native.load_inputs("retropie", truth_dir, str(root / "platforms")) + +class ACorruptOriginalIsRefused(unittest.TestCase): + """A truncated es_bios.xml in the cache was ignored: the export was + rebuilt from our model alone, losing the systems we do not transcribe + and the maintainer's comments, and the run ended in success.""" + + def test_recalbox_refuses_it(self): + fe = NativeFile("bios.bin", "bios.bin", "nes", platform={"md5": A}) + exporter = Recalbox() + with self.assertRaises(ValueError) as caught: + exporter.render({"nes": NativeSystem("nes", files=[fe])}, None, + {exporter.native_filename(): "