Skip to content

Commit fc88c0c

Browse files
committed
fix(workflows): sample aliased input types as their canonical type in mock payloads
1 parent b61c955 commit fc88c0c

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/sim/lib/workflows/triggers/run-options.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ describe('file inputs through workflow run options', () => {
115115
})
116116
})
117117

118+
describe('mock payloads for aliased field types', () => {
119+
it('samples a json field as an object the run validation accepts', () => {
120+
const [option] = resolveTriggerRunOptions({
121+
start: {
122+
type: 'start_trigger',
123+
name: 'Start',
124+
subBlocks: { inputFormat: { value: [{ name: 'payload', type: 'json' }] } },
125+
},
126+
})
127+
expect(option.mockPayload).toEqual({ payload: {} })
128+
expect(validateTriggerInput(option, option.mockPayload)).toEqual({ ok: true })
129+
})
130+
})
131+
118132
describe('workflow input discovery schemas', () => {
119133
it('matches optional defaults and describes stored-file and upload alternatives', () => {
120134
const [option] = resolveTriggerRunOptions({

‎apps/sim/lib/workflows/triggers/run-options.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
normalizeInputFormatValue,
88
parseInputFormatFiles,
99
} from '@/lib/workflows/input-format'
10+
import { canonicalInputFormatFieldType } from '@/lib/workflows/input-format-schema'
1011
import { generateWorkflowInputShape } from '@/lib/workflows/input-schema'
1112
import {
1213
getLegacyStarterMode,
@@ -128,7 +129,7 @@ function triggerOutputsToJsonSchema(outputs: Record<string, unknown>): Record<st
128129
}
129130

130131
function mockValueForType(type: string | undefined, name: string): unknown {
131-
switch (type) {
132+
switch (canonicalInputFormatFieldType(type)) {
132133
case 'number':
133134
return 42
134135
case 'boolean':

0 commit comments

Comments
 (0)