Skip to content

Commit 132f4bc

Browse files
fix(validation): don't validate disabled blocks (#2348)
1 parent d27f7c2 commit 132f4bc

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

apps/sim/serializer/index.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,35 @@ describe('Serializer', () => {
589589
}).toThrow('Test Jina Block is missing required fields: API Key')
590590
})
591591

592+
it.concurrent('should skip validation for disabled blocks', () => {
593+
const serializer = new Serializer()
594+
595+
// Create a disabled block with a missing user-only required field
596+
const disabledBlockWithMissingField: any = {
597+
id: 'test-block',
598+
type: 'jina',
599+
name: 'Disabled Jina Block',
600+
position: { x: 0, y: 0 },
601+
subBlocks: {
602+
url: { value: 'https://example.com' },
603+
apiKey: { value: null }, // Missing user-only required field
604+
},
605+
outputs: {},
606+
enabled: false, // Block is disabled
607+
}
608+
609+
// Should NOT throw error because the block is disabled
610+
expect(() => {
611+
serializer.serializeWorkflow(
612+
{ 'test-block': disabledBlockWithMissingField },
613+
[],
614+
{},
615+
undefined,
616+
true
617+
)
618+
}).not.toThrow()
619+
})
620+
592621
it.concurrent('should not throw error when all user-only required fields are present', () => {
593622
const serializer = new Serializer()
594623

apps/sim/serializer/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ export class Serializer {
429429
blockConfig: any,
430430
params: Record<string, any>
431431
) {
432+
// Skip validation if the block is disabled
433+
if (block.enabled === false) {
434+
return
435+
}
436+
432437
// Skip validation if the block is used as a trigger
433438
if (
434439
block.triggerMode === true ||

0 commit comments

Comments
 (0)