44 containsUserFileWithMetadata ,
55 hydrateUserFilesWithBase64 ,
66} from '@/lib/uploads/utils/user-file-base64.server'
7+ import { sanitizeInputFormat , sanitizeTools } from '@/lib/workflows/comparison/normalize'
78import {
89 BlockType ,
910 buildResumeApiUrl ,
@@ -34,6 +35,7 @@ import { validateBlockType } from '@/executor/utils/permission-check'
3435import type { VariableResolver } from '@/executor/variables/resolver'
3536import type { SerializedBlock } from '@/serializer/types'
3637import type { SubflowType } from '@/stores/workflows/workflow/types'
38+ import { SYSTEM_SUBBLOCK_IDS } from '@/triggers/constants'
3739
3840const logger = createLogger ( 'BlockExecutor' )
3941
@@ -87,7 +89,7 @@ export class BlockExecutor {
8789 resolvedInputs = this . resolver . resolveInputs ( ctx , node . id , block . config . params , block )
8890
8991 if ( blockLog ) {
90- blockLog . input = this . parseJsonInputs ( resolvedInputs )
92+ blockLog . input = this . sanitizeInputsForLog ( resolvedInputs )
9193 }
9294 } catch ( error ) {
9395 cleanupSelfReference ?.( )
@@ -162,7 +164,7 @@ export class BlockExecutor {
162164 ctx ,
163165 node ,
164166 block ,
165- this . parseJsonInputs ( resolvedInputs ) ,
167+ this . sanitizeInputsForLog ( resolvedInputs ) ,
166168 displayOutput ,
167169 duration
168170 )
@@ -241,7 +243,7 @@ export class BlockExecutor {
241243 blockLog . durationMs = duration
242244 blockLog . success = false
243245 blockLog . error = errorMessage
244- blockLog . input = this . parseJsonInputs ( input )
246+ blockLog . input = this . sanitizeInputsForLog ( input )
245247 blockLog . output = filterOutputForLog ( block . metadata ?. id || '' , errorOutput , { block } )
246248 }
247249
@@ -260,7 +262,7 @@ export class BlockExecutor {
260262 ctx ,
261263 node ,
262264 block ,
263- this . parseJsonInputs ( input ) ,
265+ this . sanitizeInputsForLog ( input ) ,
264266 displayOutput ,
265267 duration
266268 )
@@ -352,29 +354,41 @@ export class BlockExecutor {
352354 }
353355
354356 /**
355- * Parse JSON string inputs to objects for log display only.
356- * Attempts to parse any string that looks like JSON.
357+ * Sanitizes inputs for log display.
358+ * - Filters out system fields (UI-only, readonly, internal flags)
359+ * - Removes UI state from inputFormat items (e.g., collapsed)
360+ * - Parses JSON strings to objects for readability
357361 * Returns a new object - does not mutate the original inputs.
358362 */
359- private parseJsonInputs ( inputs : Record < string , any > ) : Record < string , any > {
360- let result = inputs
361- let hasChanges = false
363+ private sanitizeInputsForLog ( inputs : Record < string , any > ) : Record < string , any > {
364+ const result : Record < string , any > = { }
362365
363366 for ( const [ key , value ] of Object . entries ( inputs ) ) {
364- // isJSONString is a quick heuristic (checks for { or [), not a validator.
365- // Invalid JSON is safely caught below - this just avoids JSON.parse on every string.
366- if ( typeof value !== 'string' || ! isJSONString ( value ) ) {
367+ if ( SYSTEM_SUBBLOCK_IDS . includes ( key ) || key === 'triggerMode' ) {
367368 continue
368369 }
369370
370- try {
371- if ( ! hasChanges ) {
372- result = { ...inputs }
373- hasChanges = true
371+ if ( key === 'inputFormat' && Array . isArray ( value ) ) {
372+ result [ key ] = sanitizeInputFormat ( value )
373+ continue
374+ }
375+
376+ if ( key === 'tools' && Array . isArray ( value ) ) {
377+ result [ key ] = sanitizeTools ( value )
378+ continue
379+ }
380+
381+ // isJSONString is a quick heuristic (checks for { or [), not a validator.
382+ // Invalid JSON is safely caught below - this just avoids JSON.parse on every string.
383+ if ( typeof value === 'string' && isJSONString ( value ) ) {
384+ try {
385+ result [ key ] = JSON . parse ( value . trim ( ) )
386+ } catch {
387+ // Not valid JSON, keep original string
388+ result [ key ] = value
374389 }
375- result [ key ] = JSON . parse ( value . trim ( ) )
376- } catch {
377- // Not valid JSON, keep original string
390+ } else {
391+ result [ key ] = value
378392 }
379393 }
380394
0 commit comments