diff --git a/apps/sim/executor/execution/block-executor.ts b/apps/sim/executor/execution/block-executor.ts index e73f57323..616e96690 100644 --- a/apps/sim/executor/execution/block-executor.ts +++ b/apps/sim/executor/execution/block-executor.ts @@ -4,6 +4,7 @@ import { containsUserFileWithMetadata, hydrateUserFilesWithBase64, } from '@/lib/uploads/utils/user-file-base64.server' +import { sanitizeInputFormat, sanitizeTools } from '@/lib/workflows/comparison/normalize' import { BlockType, buildResumeApiUrl, @@ -34,6 +35,7 @@ import { validateBlockType } from '@/executor/utils/permission-check' import type { VariableResolver } from '@/executor/variables/resolver' import type { SerializedBlock } from '@/serializer/types' import type { SubflowType } from '@/stores/workflows/workflow/types' +import { SYSTEM_SUBBLOCK_IDS } from '@/triggers/constants' const logger = createLogger('BlockExecutor') @@ -87,7 +89,7 @@ export class BlockExecutor { resolvedInputs = this.resolver.resolveInputs(ctx, node.id, block.config.params, block) if (blockLog) { - blockLog.input = this.parseJsonInputs(resolvedInputs) + blockLog.input = this.sanitizeInputsForLog(resolvedInputs) } } catch (error) { cleanupSelfReference?.() @@ -162,7 +164,7 @@ export class BlockExecutor { ctx, node, block, - this.parseJsonInputs(resolvedInputs), + this.sanitizeInputsForLog(resolvedInputs), displayOutput, duration ) @@ -241,7 +243,7 @@ export class BlockExecutor { blockLog.durationMs = duration blockLog.success = false blockLog.error = errorMessage - blockLog.input = this.parseJsonInputs(input) + blockLog.input = this.sanitizeInputsForLog(input) blockLog.output = filterOutputForLog(block.metadata?.id || '', errorOutput, { block }) } @@ -260,7 +262,7 @@ export class BlockExecutor { ctx, node, block, - this.parseJsonInputs(input), + this.sanitizeInputsForLog(input), displayOutput, duration ) @@ -352,29 +354,41 @@ export class BlockExecutor { } /** - * Parse JSON string inputs to objects for log display only. - * Attempts to parse any string that looks like JSON. + * Sanitizes inputs for log display. + * - Filters out system fields (UI-only, readonly, internal flags) + * - Removes UI state from inputFormat items (e.g., collapsed) + * - Parses JSON strings to objects for readability * Returns a new object - does not mutate the original inputs. */ - private parseJsonInputs(inputs: Record): Record { - let result = inputs - let hasChanges = false + private sanitizeInputsForLog(inputs: Record): Record { + const result: Record = {} for (const [key, value] of Object.entries(inputs)) { - // isJSONString is a quick heuristic (checks for { or [), not a validator. - // Invalid JSON is safely caught below - this just avoids JSON.parse on every string. - if (typeof value !== 'string' || !isJSONString(value)) { + if (SYSTEM_SUBBLOCK_IDS.includes(key) || key === 'triggerMode') { continue } - try { - if (!hasChanges) { - result = { ...inputs } - hasChanges = true + if (key === 'inputFormat' && Array.isArray(value)) { + result[key] = sanitizeInputFormat(value) + continue + } + + if (key === 'tools' && Array.isArray(value)) { + result[key] = sanitizeTools(value) + continue + } + + // isJSONString is a quick heuristic (checks for { or [), not a validator. + // Invalid JSON is safely caught below - this just avoids JSON.parse on every string. + if (typeof value === 'string' && isJSONString(value)) { + try { + result[key] = JSON.parse(value.trim()) + } catch { + // Not valid JSON, keep original string + result[key] = value } - result[key] = JSON.parse(value.trim()) - } catch { - // Not valid JSON, keep original string + } else { + result[key] = value } } diff --git a/apps/sim/triggers/constants.ts b/apps/sim/triggers/constants.ts index 66258cbd4..4cceb5439 100644 --- a/apps/sim/triggers/constants.ts +++ b/apps/sim/triggers/constants.ts @@ -10,6 +10,7 @@ export const SYSTEM_SUBBLOCK_IDS: string[] = [ 'webhookUrlDisplay', // Webhook URL display 'samplePayload', // Example payload display 'setupScript', // Setup script code (e.g., Apps Script) + 'scheduleInfo', // Schedule status display (next run, last run) ] /**