Compare commits
5 Commits
8825932159
...
fix/annota
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dfd3b026b | |||
| c93f274f41 | |||
| dfa311fb5b | |||
| 3ef1dc2801 | |||
| 435e41ed4d |
@@ -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 d’annotations => index vide (ne casse pas la build)
|
||||||
|
missingRoot = true;
|
||||||
|
console.warn(`[annotations-index] Missing annotations root: ${ANNO_ROOT} (${e?.message || e})`);
|
||||||
|
files = [];
|
||||||
|
// ✅ surtout PAS d'errors.push ici
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const fp of files) {
|
for (const fp of files) {
|
||||||
@@ -177,6 +183,14 @@ export const GET: APIRoute = async () => {
|
|||||||
pg.paras = next;
|
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 = {
|
const out = {
|
||||||
schema: 1,
|
schema: 1,
|
||||||
generatedAt: new Date().toISOString(),
|
generatedAt: new Date().toISOString(),
|
||||||
@@ -186,10 +200,13 @@ export const GET: APIRoute = async () => {
|
|||||||
paras: Object.values(pages).reduce((n, p) => n + Object.keys(p.paras || {}).length, 0),
|
paras: Object.values(pages).reduce((n, p) => n + Object.keys(p.paras || {}).length, 0),
|
||||||
errors: errors.length,
|
errors: errors.length,
|
||||||
},
|
},
|
||||||
|
warnings,
|
||||||
errors,
|
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}`);
|
throw new Error(`${errors[0].file}: ${errors[0].error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user