Skip to content

Commit 0a9c4ed

Browse files
mutdmourclaude
authored andcommitted
feat(core): Expand workflow-sdk test fixtures from 500 to 2000 workflows and fix codegen bugs (#26041)
Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent ec7b147 commit 0a9c4ed

43 files changed

Lines changed: 16650 additions & 671 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/@n8n/workflow-sdk/scripts/fetch-test-workflows.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async function main() {
9898
const allWorkflowIds: number[] = [];
9999

100100
// Fetch multiple pages to get enough workflow IDs
101-
for (let page = 1; page <= 10; page++) {
101+
for (let page = 1; page <= 20; page++) {
102102
const results = await searchWorkflows(page, 100);
103103
if (results.length === 0) break;
104104

@@ -112,15 +112,15 @@ async function main() {
112112
);
113113

114114
// Stop if we have enough candidates
115-
if (allWorkflowIds.length >= 200) break;
115+
if (allWorkflowIds.length >= 2000) break;
116116
}
117117

118118
console.log(`\nFound ${allWorkflowIds.length} new workflow candidates\n`);
119119
console.log('Fetching workflows (only published)...\n');
120120

121121
const results: { id: number; name: string; success: boolean }[] = [];
122122
let publishedCount = 0;
123-
const TARGET_COUNT = 100;
123+
const TARGET_COUNT = 1000;
124124

125125
for (const id of allWorkflowIds) {
126126
if (publishedCount >= TARGET_COUNT) {

packages/@n8n/workflow-sdk/src/__tests__/fixtures-zip.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export function needsExtraction(): boolean {
5858
}
5959

6060
/**
61-
* Extract workflows from zip file
61+
* Extract workflows from zip file.
62+
* Skips manifest.json so the committed (git-tracked) manifest is preserved.
63+
* The zip may contain a stale manifest; the committed one is the source of truth
64+
* for expectedWarnings and skip flags.
6265
*/
6366
export function extractWorkflowsFromZip(): void {
6467
if (!fs.existsSync(ZIP_PATH)) {
@@ -71,7 +74,12 @@ export function extractWorkflowsFromZip(): void {
7174
}
7275

7376
const zip = new AdmZip(ZIP_PATH);
74-
zip.extractAllTo(REAL_WORKFLOWS_DIR, true); // overwrite existing
77+
for (const entry of zip.getEntries()) {
78+
if (entry.isDirectory) continue;
79+
// Skip manifest.json — the committed version is the source of truth
80+
if (entry.entryName === 'manifest.json') continue;
81+
zip.extractEntryTo(entry, REAL_WORKFLOWS_DIR, false, true);
82+
}
7583
}
7684

7785
/**

packages/@n8n/workflow-sdk/src/ast-interpreter/interpreter.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ export type SDKFunctions = Record<string, (...args: any[]) => unknown>;
3535
* Walks the AST and evaluates SDK patterns.
3636
*/
3737
class SDKInterpreter {
38+
private static readonly MAX_EVAL_DEPTH = 500;
39+
3840
private sdkFunctions: Map<string, (...args: unknown[]) => unknown>;
3941
private variables: Map<string, unknown>;
4042
private renamedVariables: Map<string, string> = new Map();
4143
private sourceCode: string;
44+
private evalDepth = 0;
4245

4346
constructor(sdkFunctions: SDKFunctions, sourceCode: string) {
4447
this.sdkFunctions = new Map(Object.entries(sdkFunctions));
@@ -136,6 +139,23 @@ class SDKInterpreter {
136139
private evaluate(node: ESTree.Expression | ESTree.SpreadElement | null): unknown {
137140
if (node === null) return undefined;
138141

142+
if (this.evalDepth >= SDKInterpreter.MAX_EVAL_DEPTH) {
143+
throw new InterpreterError(
144+
'Expression nesting too deep (possible cycle in method chain)',
145+
node.loc ?? undefined,
146+
this.sourceCode,
147+
);
148+
}
149+
150+
this.evalDepth++;
151+
try {
152+
return this.evaluateNode(node);
153+
} finally {
154+
this.evalDepth--;
155+
}
156+
}
157+
158+
private evaluateNode(node: ESTree.Expression | ESTree.SpreadElement): unknown {
139159
validateNodeType(node, this.sourceCode);
140160

141161
switch (node.type) {

0 commit comments

Comments
 (0)