Skip to content

Commit ccf9751

Browse files
committed
fix(logs): address PR review — redact workflowInput, improve fallback heuristic, add isPending guard
1 parent 06aebaa commit ccf9751

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/log-details.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ interface LogDetailsProps {
266266
hasPrev?: boolean
267267
/** Callback to retry a failed execution */
268268
onRetryExecution?: () => void
269+
/** Whether a retry is currently in progress */
270+
isRetryPending?: boolean
269271
}
270272

271273
/**
@@ -283,6 +285,7 @@ export const LogDetails = memo(function LogDetails({
283285
hasNext = false,
284286
hasPrev = false,
285287
onRetryExecution,
288+
isRetryPending = false,
286289
}: LogDetailsProps) {
287290
const [isExecutionSnapshotOpen, setIsExecutionSnapshotOpen] = useState(false)
288291
const scrollAreaRef = useRef<HTMLDivElement>(null)
@@ -399,6 +402,7 @@ export const LogDetails = memo(function LogDetails({
399402
variant='ghost'
400403
className='!p-1'
401404
onClick={() => onRetryExecution?.()}
405+
disabled={isRetryPending}
402406
aria-label='Retry execution'
403407
>
404408
<Redo className='h-[14px] w-[14px]' />

apps/sim/app/workspace/[workspaceId]/logs/components/log-row-context-menu/log-row-context-menu.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface LogRowContextMenuProps {
2424
onClearAllFilters: () => void
2525
onCancelExecution: () => void
2626
onRetryExecution: () => void
27+
isRetryPending?: boolean
2728
isFilteredByThisWorkflow: boolean
2829
hasActiveFilters: boolean
2930
}
@@ -45,6 +46,7 @@ export const LogRowContextMenu = memo(function LogRowContextMenu({
4546
onClearAllFilters,
4647
onCancelExecution,
4748
onRetryExecution,
49+
isRetryPending = false,
4850
isFilteredByThisWorkflow,
4951
hasActiveFilters,
5052
}: LogRowContextMenuProps) {
@@ -78,9 +80,9 @@ export const LogRowContextMenu = memo(function LogRowContextMenu({
7880
>
7981
{isRetryable && (
8082
<>
81-
<DropdownMenuItem onSelect={onRetryExecution}>
83+
<DropdownMenuItem onSelect={onRetryExecution} disabled={isRetryPending}>
8284
<Redo />
83-
Retry
85+
{isRetryPending ? 'Retrying...' : 'Retry'}
8486
</DropdownMenuItem>
8587
<DropdownMenuSeparator />
8688
</>

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ export default function Logs() {
821821
hasNext={selectedLogIndex < sortedLogs.length - 1}
822822
hasPrev={selectedLogIndex > 0}
823823
onRetryExecution={handleRetrySidebarExecution}
824+
isRetryPending={retryExecution.isPending}
824825
/>
825826
),
826827
[
@@ -830,6 +831,7 @@ export default function Logs() {
830831
handleNavigateNext,
831832
handleNavigatePrev,
832833
handleRetrySidebarExecution,
834+
retryExecution.isPending,
833835
selectedLogIndex,
834836
sortedLogs.length,
835837
]
@@ -1231,6 +1233,7 @@ export default function Logs() {
12311233
onOpenPreview={handleOpenPreview}
12321234
onCancelExecution={handleCancelExecution}
12331235
onRetryExecution={handleRetryExecution}
1236+
isRetryPending={retryExecution.isPending}
12341237
onToggleWorkflowFilter={handleToggleWorkflowFilter}
12351238
onClearAllFilters={handleClearAllFilters}
12361239
isFilteredByThisWorkflow={isFilteredByThisWorkflow}

apps/sim/app/workspace/[workspaceId]/logs/utils.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,19 @@ export function extractRetryInput(log: WorkflowLog): unknown | undefined {
438438
}
439439

440440
const executionState = execData.executionState as
441-
| { blockStates?: Record<string, { output?: unknown }> }
441+
| {
442+
blockStates?: Record<
443+
string,
444+
{ output?: unknown; executed?: boolean; executionTime?: number }
445+
>
446+
}
442447
| undefined
443448
if (!executionState?.blockStates) return undefined
444449

450+
// Starter/trigger blocks are pre-populated with executed: false and executionTime: 0,
451+
// which distinguishes them from blocks that actually ran during execution.
445452
for (const state of Object.values(executionState.blockStates)) {
446-
if (state.output && typeof state.output === 'object' && 'input' in state.output) {
453+
if (state.executed === false && state.executionTime === 0 && state.output != null) {
447454
return state.output
448455
}
449456
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ export class ExecutionLogger implements IExecutionLoggerService {
372372
? Math.max(0, Math.round(rawDurationMs))
373373
: 0
374374

375+
const redactedWorkflowInput =
376+
workflowInput !== undefined ? redactApiKeys(filterForDisplay(workflowInput)) : undefined
377+
375378
const completedExecutionData = this.buildCompletedExecutionData({
376379
existingExecutionData,
377380
traceSpans: redactedTraceSpans,
@@ -380,7 +383,7 @@ export class ExecutionLogger implements IExecutionLoggerService {
380383
completionFailure,
381384
executionCost,
382385
executionState,
383-
workflowInput,
386+
workflowInput: redactedWorkflowInput,
384387
})
385388

386389
const [updatedLog] = await db

0 commit comments

Comments
 (0)