Skip to content

Commit 8d8d35a

Browse files
waleedlatif1claude
andcommitted
fix(blocks): deep-clone subBlocks before mutating condition IDs
Shallow copy of subBlocks meant remapConditionIds could mutate the source data (clipboard on repeated paste, or input workflowState on import). Deep-clone subBlocks in both regenerateBlockIds and regenerateWorkflowIds to prevent this. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1e44d64 commit 8d8d35a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/sim/stores/workflows/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export function regenerateWorkflowIds(
370370
blockIdMap.set(oldId, newId)
371371
const oldNormalizedName = normalizeName(block.name)
372372
nameMap.set(oldNormalizedName, oldNormalizedName)
373-
const newBlock = { ...block, id: newId }
373+
const newBlock = { ...block, id: newId, subBlocks: JSON.parse(JSON.stringify(block.subBlocks)) }
374374
remapConditionIds(newBlock.subBlocks, {}, oldId, newId)
375375
newBlocks[newId] = newBlock
376376
})
@@ -540,6 +540,7 @@ export function regenerateBlockIds(
540540
id: newId,
541541
name: newName,
542542
position: newPosition,
543+
subBlocks: JSON.parse(JSON.stringify(block.subBlocks)),
543544
// Temporarily keep data as-is, we'll fix parentId in second pass
544545
data: block.data ? { ...block.data } : block.data,
545546
// Duplicated blocks are always unlocked so users can edit them

0 commit comments

Comments
 (0)