@@ -117,6 +117,10 @@ export async function loadDeployedWorkflowState(
117117 resolvedWorkspaceId = wfRow ?. workspaceId ?? undefined
118118 }
119119
120+ if ( ! resolvedWorkspaceId ) {
121+ throw new Error ( `Workflow ${ workflowId } has no workspace` )
122+ }
123+
120124 const { blocks : migratedBlocks } = await applyBlockMigrations (
121125 state . blocks || { } ,
122126 resolvedWorkspaceId
@@ -139,7 +143,7 @@ export async function loadDeployedWorkflowState(
139143
140144interface MigrationContext {
141145 blocks : Record < string , BlockState >
142- workspaceId ? : string
146+ workspaceId : string
143147 migrated : boolean
144148}
145149
@@ -148,7 +152,7 @@ type BlockMigration = (ctx: MigrationContext) => MigrationContext | Promise<Migr
148152function createMigrationPipeline ( migrations : BlockMigration [ ] ) {
149153 return async (
150154 blocks : Record < string , BlockState > ,
151- workspaceId ? : string
155+ workspaceId : string
152156 ) : Promise < { blocks : Record < string , BlockState > ; migrated : boolean } > => {
153157 let ctx : MigrationContext = { blocks, workspaceId, migrated : false }
154158 for ( const migration of migrations ) {
@@ -170,7 +174,6 @@ const applyBlockMigrations = createMigrationPipeline([
170174 } ) ,
171175
172176 async ( ctx ) => {
173- if ( ! ctx . workspaceId ) return ctx
174177 const { blocks, migrated } = await migrateCredentialIds ( ctx . blocks , ctx . workspaceId )
175178 return { ...ctx , blocks, migrated : ctx . migrated || migrated }
176179 } ,
@@ -409,9 +412,13 @@ export async function loadWorkflowFromNormalizedTables(
409412 blocksMap [ block . id ] = assembled
410413 } )
411414
415+ if ( ! workflowRow ?. workspaceId ) {
416+ throw new Error ( `Workflow ${ workflowId } has no workspace` )
417+ }
418+
412419 const { blocks : finalBlocks , migrated } = await applyBlockMigrations (
413420 blocksMap ,
414- workflowRow ? .workspaceId ?? undefined
421+ workflowRow . workspaceId
415422 )
416423
417424 if ( migrated ) {
0 commit comments