Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions apps/sim/socket/database/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,8 @@ async function handleEdgeOperationTx(tx: any, workflowId: string, operation: str
return false
}

if (isBlockProtected(payload.source) || isBlockProtected(payload.target)) {
logger.info(`Skipping edge add - source or target block is protected`)
if (isBlockProtected(payload.target)) {
logger.info(`Skipping edge add - target block is protected`)
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
waleedlatif1 marked this conversation as resolved.
break
}

Expand Down Expand Up @@ -1345,11 +1345,8 @@ async function handleEdgeOperationTx(tx: any, workflowId: string, operation: str
return false
}

if (
isBlockProtected(edgeToRemove.sourceBlockId) ||
isBlockProtected(edgeToRemove.targetBlockId)
) {
logger.info(`Skipping edge remove - source or target block is protected`)
Comment thread
waleedlatif1 marked this conversation as resolved.
if (isBlockProtected(edgeToRemove.targetBlockId)) {
logger.info(`Skipping edge remove - target block is protected`)
break
}

Expand Down Expand Up @@ -1470,14 +1467,11 @@ async function handleEdgesOperationTx(
}

const safeEdgeIds = edgesToRemove
.filter(
(e: EdgeToRemove) =>
!isBlockProtected(e.sourceBlockId) && !isBlockProtected(e.targetBlockId)
)
.filter((e: EdgeToRemove) => !isBlockProtected(e.targetBlockId))
.map((e: EdgeToRemove) => e.id)

if (safeEdgeIds.length === 0) {
logger.info('All edges are connected to protected blocks, skipping removal')
logger.info('All edges target protected blocks, skipping removal')
return
}

Expand Down Expand Up @@ -1569,13 +1563,13 @@ async function handleEdgesOperationTx(
return false
}

// Filter edges - only add edges where neither block is protected
// Filter edges - only add edges where target block is not protected
const safeEdges = (edges as Array<Record<string, unknown>>).filter(
(e) => !isBlockProtected(e.source as string) && !isBlockProtected(e.target as string)
(e) => !isBlockProtected(e.target as string)
)

if (safeEdges.length === 0) {
logger.info('All edges connect to protected blocks, skipping add')
logger.info('All edges target protected blocks, skipping add')
return
}

Expand Down