Skip to content

Commit d7e4b93

Browse files
fix(tables): per-group version in cascade, accurate deploy error, skip not-found for deployed groups
1 parent d8050bf commit d7e4b93

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ export function useTable({ workspaceId, tableId, queryOptions }: UseTableParams)
195195
if (group.type === 'enrichment') continue
196196
const state = workflowStates.get(group.workflowId)
197197
const blocks = (state as { blocks?: Record<string, FlattenOutputsBlockInput> } | null)?.blocks
198+
// `useWorkflowStates` only fetches the live draft, so we can only judge
199+
// "block missing" for live-mode groups. A deployed-mode group runs a
200+
// different graph we don't load client-side — don't risk a false badge.
201+
const isLiveMode = group.deploymentMode !== 'deployed'
198202
for (const out of group.outputs) {
199203
const block = blocks?.[out.blockId]
200204
const blockConfig = block?.type ? getBlock(block.type) : undefined
@@ -204,7 +208,7 @@ export function useTable({ workspaceId, tableId, queryOptions }: UseTableParams)
204208
const blockName = block?.name?.trim() || undefined
205209
// Flag a missing source block only once the workflow state has loaded
206210
// (truthy `blocks`), so a still-loading workflow never flashes the badge.
207-
const blockMissing = Boolean(blocks && out.blockId && !block)
211+
const blockMissing = Boolean(isLiveMode && blocks && out.blockId && !block)
208212
map.set(out.columnName, { blockIconInfo, blockName, blockMissing })
209213
}
210214
}

apps/sim/background/workflow-column-execution.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,12 @@ async function runWorkflowAndWriteTerminal(
162162
table: TableDefinition,
163163
group: WorkflowGroup
164164
): Promise<'completed' | 'error' | 'paused' | 'blocked'> {
165-
const {
166-
tableId,
167-
tableName,
168-
rowId,
169-
groupId,
170-
workflowId,
171-
workspaceId,
172-
executionId,
173-
dispatchId,
174-
deploymentMode,
175-
} = payload
165+
const { tableId, tableName, rowId, groupId, workflowId, workspaceId, executionId, dispatchId } =
166+
payload
167+
// Read from the live `group`, not the payload: in a cascade the payload is the
168+
// first group's snapshot, so a downstream group with a different version must
169+
// use its own setting (same reason `workflowId` is re-derived per iteration).
170+
const deploymentMode = group.deploymentMode
176171
const requestId = `wfgrp-${executionId}`
177172

178173
return runWithRequestContext({ requestId }, async () => {
@@ -399,13 +394,15 @@ async function runWorkflowAndWriteTerminal(
399394
if (deploymentMode === 'deployed') {
400395
try {
401396
normalizedData = await loadDeployedWorkflowState(workflowId, workspaceId)
402-
} catch {
397+
} catch (err) {
398+
// Surface the real reason (missing deployment vs. transient DB/migration
399+
// failure) rather than always claiming the workflow isn't deployed.
403400
await writeState({
404401
status: 'error',
405402
executionId,
406403
jobId: null,
407404
workflowId,
408-
error: 'Workflow has no deployed version',
405+
error: toError(err).message,
409406
})
410407
return 'error'
411408
}

apps/sim/lib/api/contracts/tables.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,6 @@ export const runColumnContract = defineRouteContract({
959959

960960
export type AddWorkflowGroupBodyInput = z.input<typeof addWorkflowGroupBodySchema>
961961
export type UpdateWorkflowGroupBodyInput = z.input<typeof updateWorkflowGroupBodySchema>
962-
/** Which workflow state a group runs against — shared by UI / hooks. */
963-
export type WorkflowGroupDeploymentMode = z.input<typeof workflowGroupDeploymentModeSchema>
964962
export type DeleteWorkflowGroupBodyInput = z.input<typeof deleteWorkflowGroupBodySchema>
965963
export type CancelTableRunsBodyInput = z.input<typeof cancelTableRunsBodySchema>
966964
export type RunColumnBodyInput = z.input<typeof runColumnBodySchema>

apps/sim/lib/table/workflow-columns.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import type {
2222
TableRow,
2323
TableSchema,
2424
WorkflowGroup,
25-
WorkflowGroupDeploymentMode,
2625
} from '@/lib/table/types'
2726

2827
const logger = createLogger('WorkflowGroupScheduler')
@@ -207,7 +206,6 @@ export function buildPendingRuns(
207206
groupId: group.id,
208207
workflowId: group.workflowId,
209208
...(group.enrichmentId ? { enrichmentId: group.enrichmentId } : {}),
210-
...(group.deploymentMode ? { deploymentMode: group.deploymentMode } : {}),
211209
workspaceId: table.workspaceId,
212210
executionId: generateId(),
213211
})
@@ -331,10 +329,6 @@ export interface WorkflowGroupCellPayload {
331329
enrichmentId?: string
332330
workspaceId: string
333331
executionId: string
334-
/** Which workflow state to execute: `'live'` (editable draft, default) or
335-
* `'deployed'` (latest active deployment). Copied from the group at enqueue
336-
* so a mid-run config change doesn't repoint in-flight cells. */
337-
deploymentMode?: WorkflowGroupDeploymentMode
338332
/** Owning dispatch, set by `dispatcherStep`. Lets the cell halt its dispatch
339333
* on a hard stop (e.g. usage limit). Absent for cascade/auto-fire payloads
340334
* that aren't driven by a dispatch. */

0 commit comments

Comments
 (0)