Skip to content

Commit 111c34c

Browse files
committed
fix few more inconsitencies
1 parent 8e8bca7 commit 111c34c

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/workflow-selector/workflow-selector-input.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client'
22

33
import { useMemo } from 'react'
4+
import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils'
45
import { SelectorCombobox } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/selector-combobox/selector-combobox'
56
import type { SubBlockConfig } from '@/blocks/types'
67
import type { SelectorContext } from '@/hooks/selectors/types'
@@ -40,7 +41,7 @@ export function WorkflowSelectorInput({
4041
isPreview={isPreview}
4142
previewValue={previewValue}
4243
placeholder={subBlock.placeholder || 'Select workflow...'}
43-
missingOptionLabel='Deleted Workflow'
44+
missingOptionLabel={DELETED_WORKFLOW_LABEL}
4445
/>
4546
)
4647
}

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-editor/preview-editor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
isSubBlockFeatureEnabled,
3535
isSubBlockVisibleForMode,
3636
} from '@/lib/workflows/subblocks/visibility'
37+
import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils'
3738
import { SubBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components'
3839
import { PreviewContextMenu } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-context-menu'
3940
import { PreviewWorkflow } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow'
@@ -1327,7 +1328,9 @@ function PreviewEditorContent({
13271328
) : (
13281329
<div className='flex h-full items-center justify-center bg-[var(--surface-3)]'>
13291330
<span className='text-[13px] text-[var(--text-tertiary)]'>
1330-
{isMissingChildWorkflow ? 'Deleted Workflow' : 'Unable to load preview'}
1331+
{isMissingChildWorkflow
1332+
? DELETED_WORKFLOW_LABEL
1333+
: 'Unable to load preview'}
13311334
</span>
13321335
</div>
13331336
)}

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow/components/block/block.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isSubBlockFeatureEnabled,
1010
isSubBlockVisibleForMode,
1111
} from '@/lib/workflows/subblocks/visibility'
12+
import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils'
1213
import { getDisplayValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block'
1314
import { getBlock } from '@/blocks'
1415
import { SELECTOR_TYPES_HYDRATION_REQUIRED, type SubBlockConfig } from '@/blocks/types'
@@ -112,7 +113,7 @@ function resolveWorkflowName(
112113
if (!rawValue || typeof rawValue !== 'string') return null
113114

114115
const workflowMap = useWorkflowRegistry.getState().workflows
115-
return workflowMap[rawValue]?.name ?? 'Deleted Workflow'
116+
return workflowMap[rawValue]?.name ?? DELETED_WORKFLOW_LABEL
116117
}
117118

118119
/**

apps/sim/lib/logs/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ function prepareLogData(
5050

5151
export async function emitWorkflowExecutionCompleted(log: WorkflowExecutionLog): Promise<void> {
5252
try {
53+
if (!log.workflowId) return
54+
5355
const workflowData = await db
5456
.select({ workspaceId: workflow.workspaceId })
5557
.from(workflow)

apps/sim/lib/logs/execution/logger.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ export class ExecutionLogger implements IExecutionLoggerService {
293293
}
294294

295295
try {
296-
const [wf] = await db.select().from(workflow).where(eq(workflow.id, updatedLog.workflowId))
296+
// Skip workflow lookup if workflow was deleted
297+
const wf = updatedLog.workflowId
298+
? (await db.select().from(workflow).where(eq(workflow.id, updatedLog.workflowId)))[0]
299+
: undefined
297300
if (wf) {
298301
const [usr] = await db
299302
.select({ id: userTable.id, email: userTable.email, name: userTable.name })
@@ -461,7 +464,7 @@ export class ExecutionLogger implements IExecutionLoggerService {
461464
* Maintains same logic as original execution logger for billing consistency
462465
*/
463466
private async updateUserStats(
464-
workflowId: string,
467+
workflowId: string | null,
465468
costSummary: {
466469
totalCost: number
467470
totalInputCost: number
@@ -494,6 +497,11 @@ export class ExecutionLogger implements IExecutionLoggerService {
494497
return
495498
}
496499

500+
if (!workflowId) {
501+
logger.debug('Workflow was deleted, skipping user stats update')
502+
return
503+
}
504+
497505
try {
498506
// Get the workflow record to get the userId
499507
const [workflowRecord] = await db

0 commit comments

Comments
 (0)