mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-08 22:48:14 -05:00
fix(validation): don't validate disabled blocks (#2348)
This commit is contained in:
committed by
GitHub
parent
d27f7c232b
commit
132f4bca38
@@ -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()
|
||||
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user