Skip to content

Commit ec1445a

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(workflows): normalize blank multi-select imports
1 parent 571d132 commit ec1445a

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

apps/sim/lib/workflows/sanitization/subblocks.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ vi.mock('@/blocks/registry-maps', async () => {
1212
const { partialBlockRegistry } = await import('@sim/testing/mocks/block-registry.mock')
1313
return partialBlockRegistry(
1414
await import('@/blocks/blocks/condition'),
15+
await import('@/blocks/blocks/file'),
1516
await import('@/blocks/blocks/pagerduty'),
1617
await import('@/blocks/blocks/function')
1718
)
@@ -118,6 +119,30 @@ describe('sanitizeMalformedSubBlocks', () => {
118119
})
119120

120121
describe('regular blocks (config is the schema)', () => {
122+
it('repairs scalar blanks for multi-select fields while preserving their empty arrays', () => {
123+
const block = {
124+
id: 'block-1',
125+
type: 'file_v5',
126+
subBlocks: {
127+
folderSelection: { id: 'folderSelection', type: 'folder-selector', value: '' },
128+
},
129+
}
130+
const options = { convertEmptyStringToNull: true }
131+
132+
expect(sanitizeMalformedSubBlocks(block, options).subBlocks.folderSelection.value).toBeNull()
133+
expect(
134+
sanitizeMalformedSubBlocks(
135+
{
136+
...block,
137+
subBlocks: {
138+
folderSelection: { ...block.subBlocks.folderSelection, value: [] },
139+
},
140+
},
141+
options
142+
).subBlocks.folderSelection.value
143+
).toEqual([])
144+
})
145+
121146
it('preserves declared empty dropdown choices and cleared selectors without suppressing dropdown defaults', () => {
122147
const { subBlocks } = sanitizeMalformedSubBlocks(
123148
{

apps/sim/lib/workflows/sanitization/subblocks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ const EMPTY_STRING_TYPES = new Set([
2121
])
2222

2323
function acceptsEmptyString(type: string, config?: SubBlockConfig): boolean {
24+
if (config?.multiSelect) return false
2425
if (EMPTY_STRING_TYPES.has(type) || type.endsWith('-selector')) return true
25-
if (type !== 'dropdown' || config?.multiSelect) return false
26+
if (type !== 'dropdown') return false
2627

2728
const options = typeof config?.options === 'function' ? config.options() : config?.options
2829
return options?.some((option) => option.id === '') ?? false

0 commit comments

Comments
 (0)