fix(annotations): fail-open when src/annotations is missing #204

Merged
Archicratia merged 1 commits from fix/annotations-index-fail-open-20260304-223909 into main 2026-03-04 21:42:17 +00:00

View File

@@ -112,7 +112,7 @@ export const GET: APIRoute = async () => {
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}` });
// ✅ surtout PAS d'errors.push ici
}
for (const fp of files) {
@@ -183,6 +183,14 @@ export const GET: APIRoute = async () => {
pg.paras = next;
}
const warnings: Array<{ where: string; warning: string }> = [];
if (missingRoot) {
warnings.push({
where: "src/pages/annotations-index.json.ts",
warning: `Missing annotations root "${ANNO_ROOT}" (treated as empty).`,
});
}
const out = {
schema: 1,
generatedAt: new Date().toISOString(),
@@ -192,6 +200,7 @@ export const GET: APIRoute = async () => {
paras: Object.values(pages).reduce((n, p) => n + Object.keys(p.paras || {}).length, 0),
errors: errors.length,
},
warnings,
errors,
};