fix(validation): don't validate disabled blocks (#2348)

This commit is contained in:
Vikhyath Mondreti
2025-12-12 19:02:08 -08:00
committed by GitHub
parent d27f7c232b
commit 132f4bca38
2 changed files with 34 additions and 0 deletions

View File

@@ -589,6 +589,35 @@ describe('Serializer', () => {
}).toThrow('Test Jina Block is missing required fields: API Key')
})
it.concurrent('should skip validation for disabled blocks', () => {
const serializer = new Serializer()
// Create a disabled block with a missing user-only required field
const disabledBlockWithMissingField: any = {
id: 'test-block',
type: 'jina',
name: 'Disabled Jina Block',
position: { x: 0, y: 0 },
subBlocks: {
url: { value: 'https://example.com' },
apiKey: { value: null }, // Missing user-only required field
},
outputs: {},
enabled: false, // Block is disabled
}
// Should NOT throw error because the block is disabled
expect(() => {
serializer.serializeWorkflow(
{ 'test-block': disabledBlockWithMissingField },
[],
{},
undefined,
true
)
}).not.toThrow()
})
it.concurrent('should not throw error when all user-only required fields are present', () => {
const serializer = new Serializer()

View File

@@ -429,6 +429,11 @@ export class Serializer {
blockConfig: any,
params: Record<string, any>
) {
// Skip validation if the block is disabled
if (block.enabled === false) {
return
}
// Skip validation if the block is used as a trigger
if (
block.triggerMode === true ||