Skip to content

Commit ca6bd9c

Browse files
committed
fix(file): preserve validation for malformed content
1 parent a5d6549 commit ca6bd9c

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

apps/sim/blocks/blocks/file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,8 +1964,8 @@ export const FileV5Block: BlockConfig<FileParserV3Output> = {
19641964
* Explicitly clear unused Content because the executor merges these params
19651965
* over the original inputs. Preserve empty text when no file is selected.
19661966
*/
1967-
const contentText = typeof params.content === 'string' ? params.content : undefined
1968-
const omitContent = Boolean(fileInput) && !contentText
1967+
const omitContent =
1968+
Boolean(fileInput) && (params.content == null || params.content === '')
19691969
return {
19701970
fileName: params.fileName,
19711971
folderPath: optionalText(params.writeFolderRef),

apps/sim/executor/handlers/generic/file-write.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ describe('File Write executor inputs', () => {
6969
])
7070
})
7171

72+
it.each([0, false, { text: 'invalid' }, ['invalid']])(
73+
'rejects non-string Content %j alongside a file',
74+
async (content) => {
75+
const result = await executeWrite({ content, writeFileInput: generatedFile })
76+
77+
expect(result.success).toBe(false)
78+
if (result.success) throw new Error('Expected malformed Content to fail validation')
79+
expect(result.error.issues).toEqual(
80+
expect.arrayContaining([
81+
expect.objectContaining({ path: ['content'], code: 'invalid_type' }),
82+
])
83+
)
84+
}
85+
)
86+
7287
it.each(['', 'text'])('preserves text-only Content %j', async (content) => {
7388
const result = await executeWrite({ content })
7489

0 commit comments

Comments
 (0)