mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-03-29 13:43:08 +00:00
fix: handle null/invalid nodes_used in metadata generation
Fixed TypeError when generating metadata for templates with missing or invalid nodes_used data. Added safe JSON parsing with fallback to empty array. Root cause: Template -1000 (Canonical AI Tool Examples) has null nodes_used field, causing iteration error in summarizeNodes(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
BIN
data/nodes.db
BIN
data/nodes.db
Binary file not shown.
@@ -418,11 +418,27 @@ async function generateTemplateMetadata(db: any, service: TemplateService) {
|
|||||||
console.warn(`Failed to parse workflow for template ${t.id}:`, error);
|
console.warn(`Failed to parse workflow for template ${t.id}:`, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse nodes_used safely
|
||||||
|
let nodes: string[] = [];
|
||||||
|
try {
|
||||||
|
if (t.nodes_used) {
|
||||||
|
nodes = JSON.parse(t.nodes_used);
|
||||||
|
// Ensure it's an array
|
||||||
|
if (!Array.isArray(nodes)) {
|
||||||
|
console.warn(`Template ${t.id} has invalid nodes_used (not an array), using empty array`);
|
||||||
|
nodes = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Failed to parse nodes_used for template ${t.id}:`, error);
|
||||||
|
nodes = [];
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
templateId: t.id,
|
templateId: t.id,
|
||||||
name: t.name,
|
name: t.name,
|
||||||
description: t.description,
|
description: t.description,
|
||||||
nodes: JSON.parse(t.nodes_used),
|
nodes: nodes,
|
||||||
workflow
|
workflow
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user