From 435e41ed4d6530cb83d5ea2fd410a0a8f2b3ac9c Mon Sep 17 00:00:00 2001 From: Archicratia Date: Wed, 4 Mar 2026 21:31:53 +0100 Subject: [PATCH] fix(annotations): fail-open when src/annotations missing + keep dir tracked --- src/pages/annotations-index.json.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/annotations-index.json.ts b/src/pages/annotations-index.json.ts index 6f90970..a81f346 100644 --- a/src/pages/annotations-index.json.ts +++ b/src/pages/annotations-index.json.ts @@ -103,10 +103,16 @@ export const GET: APIRoute = async () => { const errors: Array<{ file: string; error: string }> = []; let files: string[] = []; + let missingRoot = false; + try { files = await walk(ANNO_ROOT); } catch (e: any) { - throw new Error(`Missing annotations root: ${ANNO_ROOT} (${e?.message || e})`); + // ✅ FAIL-OPEN : pas d’annotations => index vide (ne casse pas la build) + missingRoot = true; + console.warn(`[annotations-index] Missing annotations root: ${ANNO_ROOT} (${e?.message || e})`); + files = []; + errors.push({ file: "src/annotations", error: `Missing annotations root: ${e?.message || e}` }); } for (const fp of files) { @@ -189,7 +195,9 @@ export const GET: APIRoute = async () => { errors, }; - if (errors.length) { + // ✅ FAIL-OPEN uniquement si le dossier manque. + // Si le dossier existe mais qu’un YAML est cassé -> fail-closed. + if (errors.length && !missingRoot) { throw new Error(`${errors[0].file}: ${errors[0].error}`); } -- 2.49.1