Skip to content

Commit 125a02e

Browse files
committed
apply block migrations in missed cases
1 parent 31d640e commit 125a02e

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

apps/sim/app/api/workflows/[id]/deployments/[version]/revert/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
66
import { env } from '@/lib/core/config/env'
77
import { generateRequestId } from '@/lib/core/utils/request'
88
import { syncMcpToolsForWorkflow } from '@/lib/mcp/workflow-mcp-sync'
9-
import { saveWorkflowToNormalizedTables } from '@/lib/workflows/persistence/utils'
9+
import {
10+
applyBlockMigrations,
11+
saveWorkflowToNormalizedTables,
12+
} from '@/lib/workflows/persistence/utils'
1013
import { validateWorkflowPermissions } from '@/lib/workflows/utils'
1114
import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils'
1215

@@ -73,8 +76,13 @@ export async function POST(
7376
return createErrorResponse('Invalid deployed state structure', 500)
7477
}
7578

79+
const { blocks: migratedBlocks } = await applyBlockMigrations(
80+
deployedState.blocks,
81+
workflowRecord?.workspaceId ?? undefined
82+
)
83+
7684
const saveResult = await saveWorkflowToNormalizedTables(id, {
77-
blocks: deployedState.blocks,
85+
blocks: migratedBlocks,
7886
edges: deployedState.edges,
7987
loops: deployedState.loops || {},
8088
parallels: deployedState.parallels || {},

apps/sim/app/api/workflows/[id]/deployments/[version]/route.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
77
import { generateRequestId } from '@/lib/core/utils/request'
88
import { syncMcpToolsForWorkflow } from '@/lib/mcp/workflow-mcp-sync'
99
import { restorePreviousVersionWebhooks, saveTriggerWebhooksForDeploy } from '@/lib/webhooks/deploy'
10-
import { activateWorkflowVersion } from '@/lib/workflows/persistence/utils'
10+
import { activateWorkflowVersion, applyBlockMigrations } from '@/lib/workflows/persistence/utils'
1111
import {
1212
cleanupDeploymentVersion,
1313
createSchedulesForDeploy,
@@ -78,7 +78,13 @@ export async function GET(
7878
return createErrorResponse('Deployment version not found', 404)
7979
}
8080

81-
return createSuccessResponse({ deployedState: row.state })
81+
const state = row.state as { blocks?: Record<string, BlockState> }
82+
if (state.blocks) {
83+
const { blocks } = await applyBlockMigrations(state.blocks)
84+
state.blocks = blocks
85+
}
86+
87+
return createSuccessResponse({ deployedState: state })
8288
} catch (error: any) {
8389
logger.error(
8490
`[${requestId}] Error fetching deployment version ${version} for workflow ${id}`,

apps/sim/lib/workflows/persistence/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function createMigrationPipeline(migrations: BlockMigration[]) {
158158
}
159159
}
160160

161-
const applyBlockMigrations = createMigrationPipeline([
161+
export const applyBlockMigrations = createMigrationPipeline([
162162
(ctx) => {
163163
const { blocks } = sanitizeAgentToolsInBlocks(ctx.blocks)
164164
return { ...ctx, blocks }

0 commit comments

Comments
 (0)