Skip to content

Commit 3c1914c

Browse files
committed
Fix loop/parallel yaml
1 parent 218041d commit 3c1914c

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

apps/sim/lib/workflows/yaml-generator.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ function extractBlockInputs(
4141
if (blockState.data) {
4242
Object.entries(blockState.data).forEach(([key, value]) => {
4343
// Include relevant configuration properties
44-
if (key === 'count' || key === 'loopType' || key === 'collection' ||
45-
key === 'parallelType' || key === 'distribution') {
44+
if (
45+
key === 'count' ||
46+
key === 'loopType' ||
47+
key === 'collection' ||
48+
key === 'parallelType' ||
49+
key === 'distribution'
50+
) {
4651
if (value !== undefined && value !== null && value !== '') {
4752
inputs[key] = value
4853
}
@@ -54,14 +59,14 @@ function extractBlockInputs(
5459
}
5560
})
5661
}
57-
62+
5863
// Include any additional values from subBlockValues that might not be in data
5964
Object.entries(blockSubBlockValues).forEach(([key, value]) => {
60-
if (value !== undefined && value !== null && value !== '' && !inputs.hasOwnProperty(key)) {
65+
if (value !== undefined && value !== null && value !== '' && !Object.hasOwn(inputs, key)) {
6166
inputs[key] = value
6267
}
6368
})
64-
69+
6570
return inputs
6671
}
6772

apps/sim/stores/workflows/yaml/importer.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,44 +266,44 @@ function sortBlocksByParentChildOrder(blocks: ImportedBlock[]): ImportedBlock[]
266266
const sorted: ImportedBlock[] = []
267267
const processed = new Set<string>()
268268
const visiting = new Set<string>() // Track blocks currently being processed to detect cycles
269-
269+
270270
// Create a map for quick lookup
271271
const blockMap = new Map<string, ImportedBlock>()
272-
blocks.forEach(block => blockMap.set(block.id, block))
273-
272+
blocks.forEach((block) => blockMap.set(block.id, block))
273+
274274
// Process blocks recursively, ensuring parents are added first
275275
function processBlock(block: ImportedBlock) {
276276
if (processed.has(block.id)) {
277277
return // Already processed
278278
}
279-
279+
280280
if (visiting.has(block.id)) {
281281
// Circular dependency detected - break the cycle by processing this block without its parent
282282
logger.warn(`Circular parent-child dependency detected for block ${block.id}, breaking cycle`)
283283
sorted.push(block)
284284
processed.add(block.id)
285285
return
286286
}
287-
287+
288288
visiting.add(block.id)
289-
289+
290290
// If this block has a parent, ensure the parent is processed first
291291
if (block.parentId) {
292292
const parentBlock = blockMap.get(block.parentId)
293293
if (parentBlock && !processed.has(block.parentId)) {
294294
processBlock(parentBlock)
295295
}
296296
}
297-
297+
298298
// Now process this block
299299
visiting.delete(block.id)
300300
sorted.push(block)
301301
processed.add(block.id)
302302
}
303-
303+
304304
// Process all blocks
305-
blocks.forEach(block => processBlock(block))
306-
305+
blocks.forEach((block) => processBlock(block))
306+
307307
return sorted
308308
}
309309

@@ -623,8 +623,8 @@ export async function importWorkflowFromYaml(
623623
} else {
624624
logger.warn(`Parent block not found for mapping: ${blockData.data.parentId}`)
625625
// Remove invalid parent reference
626-
delete blockData.data.parentId
627-
delete blockData.data.extent
626+
blockData.data.parentId = undefined
627+
blockData.data.extent = undefined
628628
}
629629
}
630630
}

0 commit comments

Comments
 (0)