Skip to content

Commit b32a2a2

Browse files
committed
refactor: add validation for startingNodeId in flow execution to ensure proper flow connectivity
1 parent 78cae15 commit b32a2a2

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/validation/getFlowValidation.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ export const getFlowValidation = (
1212
): ValidationResult => {
1313

1414

15+
if (!flow?.startingNodeId) {
16+
return {
17+
isValid: false,
18+
returnType: "void",
19+
diagnostics: [{
20+
nodeId: null,
21+
parameterIndex: null,
22+
code: 0,
23+
message: "You need to provide a starting node to be able to execute this flow.",
24+
severity: "error",
25+
}]
26+
}
27+
}
28+
29+
if (!flow.nodes?.nodes?.find(n => n?.id == flow.startingNodeId)) {
30+
return {
31+
isValid: false,
32+
returnType: "void",
33+
diagnostics: [{
34+
nodeId: null,
35+
parameterIndex: null,
36+
code: 0,
37+
message: "The starting node is not linked within the flow. Please make sure the starting node is connected to the rest of the flow.",
38+
severity: "error",
39+
}]
40+
}
41+
}
42+
1543
const sourceCode = generateFlowSourceCode(flow, functions, dataTypes);
1644

1745
// 3. Virtual TypeScript Compilation

0 commit comments

Comments
 (0)