From b96a1dda2aeac370c8001b35a7eacace222986d4 Mon Sep 17 00:00:00 2001 From: androosio <295408038+androosio@users.noreply.github.com> Date: Sun, 21 Jun 2026 14:48:55 +0200 Subject: [PATCH] fix: guard SiblingBadge against missing sibling_roms The `scan:scanning_rom` socket emit strips `sibling_roms` from the rom payload, so a freshly-scanned rom can reach SiblingBadge with the field undefined (despite the schema typing it as required). Reading `.length`/`.map` then threw `TypeError: Cannot read properties of undefined (reading 'length')`, crashing the gallery during a scan while "Group ROMs" was enabled. Default `sibling_roms` to an empty list (a `siblings` computed). REST payloads always include it (possibly empty), so only the socket path was affected. Closes #3567 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/v2/components/GameCard/SiblingBadge.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/v2/components/GameCard/SiblingBadge.vue b/frontend/src/v2/components/GameCard/SiblingBadge.vue index e624f2b52..b81775a00 100644 --- a/frontend/src/v2/components/GameCard/SiblingBadge.vue +++ b/frontend/src/v2/components/GameCard/SiblingBadge.vue @@ -42,11 +42,18 @@ const { groupRoms } = useUISettings(); // "pinned" pattern GameActionBtn uses for `more` / `status` menus). const menuOpen = ref(false); +// The scan socket (`scan:scanning_rom`) emits roms with `sibling_roms` +// stripped from the payload, so it can be undefined here even though the +// type marks it required. Default to an empty list — otherwise reading +// `.length`/`.map` throws while a scan streams roms and `groupRoms` is on. +// REST payloads always include it (possibly empty). +const siblings = computed(() => props.rom.sibling_roms ?? []); + const visible = computed( - () => groupRoms.value === true && props.rom.sibling_roms.length > 0, + () => groupRoms.value === true && siblings.value.length > 0, ); -const totalCount = computed(() => props.rom.sibling_roms.length + 1); +const totalCount = computed(() => siblings.value.length + 1); const tooltipText = computed(() => t("rom.versions-count", { n: totalCount.value }), @@ -65,7 +72,7 @@ const versions = computed(() => [ current: true, main: props.rom.rom_user?.is_main_sibling === true, }, - ...props.rom.sibling_roms.map((s) => ({ + ...siblings.value.map((s) => ({ id: s.id, label: s.fs_name_no_ext, current: false,