From 3d2a3534b4b7f3fe8173dfa89c275b8a799cc58c Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Wed, 19 Aug 2026 15:02:22 +0200 Subject: [PATCH] fix(examples): tolerate missing components/wires in an example def The interface requires both fields but the Docker build never type-checks the pro overlay's example data (vite build only), so a missing field shipped and loadExample's unguarded .filter/.map threw - the page surfaced as a sticky 404 on a registered example (four SensAirShuttle examples on staging). Load an armless example as having none instead; authoring still declares the fields required. --- frontend/src/utils/loadExample.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/utils/loadExample.ts b/frontend/src/utils/loadExample.ts index d09564c0..901828cb 100644 --- a/frontend/src/utils/loadExample.ts +++ b/frontend/src/utils/loadExample.ts @@ -74,7 +74,7 @@ function seedChipProgramGroups(example: ExampleProject): { const programFileNames = new Set(); const chipGroupIds: string[] = []; - for (const comp of example.components) { + for (const comp of example.components ?? []) { if (stripBrandPrefix(comp.type) !== 'custom-chip') continue; const pf = String( (comp.properties as Record)?.programFile ?? '', @@ -227,7 +227,7 @@ export async function loadExample( // shows as its own section (the per-board code came from eb.code above). seedChipProgramGroups(example); - const componentsWithoutBoard = example.components.filter( + const componentsWithoutBoard = (example.components ?? []).filter( (comp) => !comp.type.includes('arduino') && !comp.type.includes('pico') && @@ -245,7 +245,7 @@ export async function loadExample( ); setWires( - example.wires.map((wire) => ({ + (example.wires ?? []).map((wire) => ({ id: wire.id, start: { componentId: wire.start.componentId, pinName: wire.start.pinName, x: 0, y: 0 }, end: { componentId: wire.end.componentId, pinName: wire.end.pinName, x: 0, y: 0 }, @@ -346,7 +346,7 @@ export async function loadExample( editorStore.setCode(example.code); } - const componentsWithoutBoard = example.components.filter( + const componentsWithoutBoard = (example.components ?? []).filter( (comp) => !comp.type.includes('arduino') && !comp.type.includes('pico') && @@ -383,7 +383,7 @@ export async function loadExample( isBoardComponent(id) && liveActiveBoardId ? liveActiveBoardId : id; setWires( - example.wires.map((wire) => ({ + (example.wires ?? []).map((wire) => ({ id: wire.id, start: { componentId: remapBoardId(wire.start.componentId),