From f225a99f899c8331f7b5a3dd08fe19152b919798 Mon Sep 17 00:00:00 2001 From: TowyTowy Date: Fri, 17 Jul 2026 01:04:45 +0200 Subject: [PATCH] fix(platforms): include TGDB handler in tgdb_id fallback for supported platforms get_supported_platforms() resolved tgdb_id from the MobyGames and Hasheous platform entries only, but MobyGames platforms never carry a tgdb_id and the Hasheous platform list has no TGDB mappings, so the explicit key always overrode the value spread from the TGDB handler with None. Mirror the fallback chain used during scans in scan_handler.py by falling back to the TGDB platform entry itself. Co-Authored-By: Claude --- backend/tests/utils/test_platforms.py | 15 +++++++++++++++ backend/utils/platforms.py | 1 + 2 files changed, 16 insertions(+) diff --git a/backend/tests/utils/test_platforms.py b/backend/tests/utils/test_platforms.py index ee7eccba6..f14af9d13 100644 --- a/backend/tests/utils/test_platforms.py +++ b/backend/tests/utils/test_platforms.py @@ -23,3 +23,18 @@ def test_supported_platform_not_shadowed_by_variant(): assert arcade.name == "Arcade" assert arcade.fs_slug == "arcade" + + +def test_supported_platform_keeps_tgdb_id_from_tgdb(): + """The TGDB platform ID must survive the metadata merge. + + Regression for the tgdb_id fallback chain missing the TGDB handler + itself: MobyGames platforms never carry a tgdb_id and the Hasheous + platform list has no TGDB mappings, so every unmatched platform was + reported with tgdb_id=None even when TGDB knows the platform. + """ + supported = get_supported_platforms() + threedo = next(p for p in supported if p.slug == "3do") + + # TGDB maps the 3DO platform to ID 25. + assert threedo.tgdb_id == 25 diff --git a/backend/utils/platforms.py b/backend/utils/platforms.py index 42b338f43..104438bfd 100644 --- a/backend/utils/platforms.py +++ b/backend/utils/platforms.py @@ -90,6 +90,7 @@ def get_supported_platforms() -> list[PlatformSchema]: or None, "tgdb_id": moby_platform.get("tgdb_id") or hasheous_platform.get("tgdb_id") + or tgdb_platform.get("tgdb_id") or None, "name": igdb_platform.get("name") or ss_platform.get("name")