Merge pull request 'fix(annotations): fail-open when src/annotations missing + keep dir tracked' (#203) from chore/remove-test-anno-media-20260304-204810 into main
All checks were successful
SMOKE / smoke (push) Successful in 13s
CI / build-and-anchors (push) Successful in 44s
Deploy staging+live (annotations) / deploy (push) Successful in 8m47s

Reviewed-on: #203
This commit was merged in pull request #203.
This commit is contained in:
2026-03-04 21:39:04 +01:00

View File

@@ -103,10 +103,16 @@ export const GET: APIRoute = async () => {
const errors: Array<{ file: string; error: string }> = []; const errors: Array<{ file: string; error: string }> = [];
let files: string[] = []; let files: string[] = [];
let missingRoot = false;
try { try {
files = await walk(ANNO_ROOT); files = await walk(ANNO_ROOT);
} catch (e: any) { } catch (e: any) {
throw new Error(`Missing annotations root: ${ANNO_ROOT} (${e?.message || e})`); // ✅ FAIL-OPEN : pas dannotations => 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) { for (const fp of files) {
@@ -189,7 +195,9 @@ export const GET: APIRoute = async () => {
errors, errors,
}; };
if (errors.length) { // ✅ FAIL-OPEN uniquement si le dossier manque.
// Si le dossier existe mais quun YAML est cassé -> fail-closed.
if (errors.length && !missingRoot) {
throw new Error(`${errors[0].file}: ${errors[0].error}`); throw new Error(`${errors[0].file}: ${errors[0].error}`);
} }