fix(f4): harden schema-columns enrichment + ValidationError guard + staged-helper note

This commit is contained in:
2026-07-06 23:25:00 +02:00
committed by Marco Pancotti
parent 3ed570ee60
commit d942635085
4 changed files with 71 additions and 6 deletions
+14 -5
View File
@@ -651,10 +651,19 @@ export default function (pi) {
const phase = phaseId(ctx, currentPhase(ctx, session));
// Enrich each table with its full catalog columns (deterministic source).
const enriched = tables.map((t) => {
const cat = JSON.parse(tht(ctx, ["schema", "columns", t.name, "--json"]));
const enriched = [];
for (const t of tables) {
let cat;
try {
cat = JSON.parse(tht(ctx, ["schema", "columns", t.name, "--json"]));
} catch (e) {
const msg = (e.stderr || e.message || String(e)).toString().trim();
return textResult(
`Tabella '${t.name}' non caricabile dal catalogo (${msg}). Proponi solo tabelle presenti nel catalogo (usa 'tht schema render' / 'tht search' per verificarne i nomi).`,
);
}
const suggested = new Set(t.suggested_columns ?? []);
return {
enriched.push({
id: t.id,
name: t.name,
kind: t.kind,
@@ -662,8 +671,8 @@ export default function (pi) {
description: cat.description ?? "",
rationale: t.rationale ?? "",
columns: cat.columns.map((c) => ({ ...c, suggested: suggested.has(c.name) })),
};
});
});
}
const widget = buildSchemaLinkingRequest({
id: `u${Date.now()}`,